Example usage for org.hibernate.action.internal EntityUpdateAction getInstance

List of usage examples for org.hibernate.action.internal EntityUpdateAction getInstance

Introduction

In this page you can find the example usage for org.hibernate.action.internal EntityUpdateAction getInstance.

Prototype

public final Object getInstance() 

Source Link

Document

entity instance accessor

Usage

From source file:org.grails.orm.hibernate.support.ClosureEventListener.java

License:Apache License

protected void synchronizeEntityUpdateActionState(AbstractPreDatabaseOperationEvent event, Object entity,
        HashMap<Integer, Object> changedState) {
    if (actionQueueUpdatesField != null && event instanceof PreInsertEvent && changedState.size() > 0) {
        try {// ww w  .j  a v a2 s. co m
            ExecutableList<EntityUpdateAction> updates = (ExecutableList<EntityUpdateAction>) actionQueueUpdatesField
                    .get(event.getSource().getActionQueue());
            if (updates != null) {
                for (EntityUpdateAction updateAction : updates) {
                    if (updateAction.getInstance() == entity) {
                        Object[] updateState = (Object[]) entityUpdateActionStateField.get(updateAction);
                        if (updateState != null) {
                            for (Map.Entry<Integer, Object> entry : changedState.entrySet()) {
                                updateState[entry.getKey()] = entry.getValue();
                            }
                        }
                    }
                }
            }
        } catch (Exception e) {
            LOG.warn("Exception in synchronizeEntityUpdateActionState", e);
        }
    }
}