org.hibernate.action.internal.EntityUpdateAction Java Examples
The following examples show how to use
org.hibernate.action.internal.EntityUpdateAction.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ClosureEventListener.java From gorm-hibernate5 with Apache License 2.0 | 6 votes |
private void synchronizeEntityUpdateActionState(AbstractPreDatabaseOperationEvent event, Object entity, HashMap<Integer, Object> changedState) { if(actionQueueUpdatesField != null && event instanceof PreInsertEvent && changedState.size() > 0) { try { ExecutableList<EntityUpdateAction> updates = (ExecutableList<EntityUpdateAction>)actionQueueUpdatesField.get(event.getSession().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("Error synchronizing object state with Hibernate: " + e.getMessage(), e); } } }
Example #2
Source File: ActionQueue.java From lams with GNU General Public License v2.0 | 4 votes |
ExecutableList<EntityUpdateAction> get(ActionQueue instance) { return instance.updates; }
Example #3
Source File: ActionQueue.java From lams with GNU General Public License v2.0 | 4 votes |
ExecutableList<EntityUpdateAction> init(ActionQueue instance) { return instance.updates = new ExecutableList<EntityUpdateAction>( instance.isOrderUpdatesEnabled() ); }
Example #4
Source File: DefaultFlushEntityEventListener.java From lams with GNU General Public License v2.0 | 4 votes |
private boolean scheduleUpdate(final FlushEntityEvent event) { final EntityEntry entry = event.getEntityEntry(); final EventSource session = event.getSession(); final Object entity = event.getEntity(); final Status status = entry.getStatus(); final EntityPersister persister = entry.getPersister(); final Object[] values = event.getPropertyValues(); if ( LOG.isTraceEnabled() ) { if ( status == Status.DELETED ) { if ( !persister.isMutable() ) { LOG.tracev( "Updating immutable, deleted entity: {0}", MessageHelper.infoString( persister, entry.getId(), session.getFactory() ) ); } else if ( !entry.isModifiableEntity() ) { LOG.tracev( "Updating non-modifiable, deleted entity: {0}", MessageHelper.infoString( persister, entry.getId(), session.getFactory() ) ); } else { LOG.tracev( "Updating deleted entity: ", MessageHelper.infoString( persister, entry.getId(), session.getFactory() ) ); } } else { LOG.tracev( "Updating entity: {0}", MessageHelper.infoString( persister, entry.getId(), session.getFactory() ) ); } } final boolean intercepted = !entry.isBeingReplicated() && handleInterception( event ); // increment the version number (if necessary) final Object nextVersion = getNextVersion( event ); // if it was dirtied by a collection only int[] dirtyProperties = event.getDirtyProperties(); if ( event.isDirtyCheckPossible() && dirtyProperties == null ) { if ( !intercepted && !event.hasDirtyCollection() ) { throw new AssertionFailure( "dirty, but no dirty properties" ); } dirtyProperties = ArrayHelper.EMPTY_INT_ARRAY; } // check nullability but do not doAfterTransactionCompletion command execute // we'll use scheduled updates for that. new Nullability( session ).checkNullability( values, persister, true ); // schedule the update // note that we intentionally do _not_ pass in currentPersistentState! session.getActionQueue().addAction( new EntityUpdateAction( entry.getId(), values, dirtyProperties, event.hasDirtyCollection(), ( status == Status.DELETED && !entry.isModifiableEntity() ? persister.getPropertyValues( entity ) : entry.getLoadedState() ), entry.getVersion(), nextVersion, entity, entry.getRowId(), persister, session ) ); return intercepted; }
Example #5
Source File: ClosureEventListener.java From gorm-hibernate5 with Apache License 2.0 | 4 votes |
public ClosureEventListener(PersistentEntity persistentEntity, boolean failOnError, List failOnErrorPackages) { this.persistentEntity = persistentEntity; Class domainClazz = persistentEntity.getJavaClass(); this.domainMetaClass = GroovySystem.getMetaClassRegistry().getMetaClass(domainClazz); this.isMultiTenant = ClassUtils.isMultiTenant(domainClazz); saveOrUpdateCaller = buildCaller(AbstractPersistenceEvent.ONLOAD_SAVE, domainClazz); beforeInsertCaller = buildCaller(AbstractPersistenceEvent.BEFORE_INSERT_EVENT, domainClazz); EventTriggerCaller preLoadEventCaller = buildCaller(AbstractPersistenceEvent.ONLOAD_EVENT, domainClazz); if (preLoadEventCaller == null) { this.preLoadEventCaller = buildCaller(AbstractPersistenceEvent.BEFORE_LOAD_EVENT, domainClazz); } else { this.preLoadEventCaller = preLoadEventCaller; } postLoadEventListener = buildCaller(AbstractPersistenceEvent.AFTER_LOAD_EVENT, domainClazz); postInsertEventListener = buildCaller(AbstractPersistenceEvent.AFTER_INSERT_EVENT, domainClazz); postUpdateEventListener = buildCaller(AbstractPersistenceEvent.AFTER_UPDATE_EVENT, domainClazz); postDeleteEventListener = buildCaller(AbstractPersistenceEvent.AFTER_DELETE_EVENT, domainClazz); preDeleteEventListener = buildCaller(AbstractPersistenceEvent.BEFORE_DELETE_EVENT, domainClazz); preUpdateEventListener = buildCaller(AbstractPersistenceEvent.BEFORE_UPDATE_EVENT, domainClazz); beforeValidateEventListener = new BeforeValidateEventTriggerCaller(domainClazz, domainMetaClass); if (failOnErrorPackages.size() > 0) { failOnErrorEnabled = ClassUtils.isClassBelowPackage(domainClazz, failOnErrorPackages); } else { failOnErrorEnabled = failOnError; } validateParams = new HashMap(); validateParams.put(AbstractHibernateGormValidationApi.ARGUMENT_DEEP_VALIDATE, Boolean.FALSE); try { actionQueueUpdatesField=ReflectionUtils.findField(ActionQueue.class, "updates"); actionQueueUpdatesField.setAccessible(true); entityUpdateActionStateField=ReflectionUtils.findField(EntityUpdateAction.class, "state"); entityUpdateActionStateField.setAccessible(true); } catch (Exception e) { // ignore } }
Example #6
Source File: ActionQueue.java From lams with GNU General Public License v2.0 | 2 votes |
/** * Adds an entity update action * * @param action The action representing the entity update */ public void addAction(EntityUpdateAction action) { addAction( EntityUpdateAction.class, action ); }