@Override public void postUpdate(DescriptorEvent event) { Object txId = event.getSession().getProperty(ORA_TRANSACTION_ID); if (txId == null) { txId = event.getSession().executeQuery(transactionIdQuery); event.getSession().setProperty(ORA_TRANSACTION_ID, txId); } } });
@Override public void postUpdate(DescriptorEvent event) { Object txId = event.getSession().getProperty(ORA_TRANSACTION_ID); if (txId == null) { txId = event.getSession().executeQuery(transactionIdQuery); event.getSession().setProperty(ORA_TRANSACTION_ID, txId); } } });
@Override public void preUpdate (DescriptorEvent event) { Object source = event.getSource(); UnitOfWorkImpl unitOfWork = (UnitOfWorkImpl )event.getSession(); // preUpdate is also generated for deleted objects that were modified in this UOW. // Do not perform preUpdate validation for such objects as preRemove would have already been called. if(!unitOfWork.isObjectDeleted(source)) { validateOnCallbackEvent(event, "preUpdate", groupPreUpdate); } }
@Override public void postDelete(DescriptorEvent event) { String storeName = support.getStorageName(event.getSession()); manager.fireListener((Entity) event.getSource(), EntityListenerType.AFTER_DELETE, storeName); }
@Override public void postInsert(DescriptorEvent event) { Entity entity = (Entity) event.getSource(); String storeName = support.getStorageName(event.getSession()); manager.fireListener(entity, EntityListenerType.AFTER_INSERT, storeName); support.getSavedInstances(storeName).add(entity); }
/** * PUBLIC: * The source object represents the object the event is being raised on, * some events also require a second object, for example the original object in a postClone. * * @see EventObject#getSource() */ public Object getOriginalObject() { // Compute the original for unit of work writes. if ((originalObject == null) && getSession().isUnitOfWork() && (getQuery() != null) && (getQuery().isObjectLevelModifyQuery())) { setOriginalObject(((UnitOfWorkImpl)getSession()).getOriginalVersionOfObject(getSource())); } return originalObject; }
/** * PUBLIC: * The source object represents the object the event is being raised on, * some events also require a second object, for example the original object in a postClone. * * @see EventObject#getSource() */ public Object getOriginalObject() { // Compute the original for unit of work writes. if ((originalObject == null) && getSession().isUnitOfWork() && (getQuery() != null) && (getQuery().isObjectLevelModifyQuery())) { setOriginalObject(((UnitOfWorkImpl)getSession()).getOriginalVersionOfObject(getSource())); } return originalObject; }
public void postUpdate(DescriptorEvent event) { if (disable()) { return; } Object entity = event.getObject(); if (!hasMappingForEntity(entity.getClass(), Cascade.SAVE)) { return; } try { if (log.isDebugEnabled()) { log.debug("Updating [" + entity + "]"); } Session session = event.getSession(); EclipseLinkHelper.getCurrentCompassSession(session).save(entity); } catch (Exception e) { log.error("Failed while updating [" + entity + "]", e); if (throwExceptionOnError()) { throw new JpaGpsDeviceException("Failed while updating [" + entity + "]", e); } } }
/** * PUBLIC: * The source object represents the object the event is being raised on, * some events also require a second object, for example the original object in a postClone. * * @see EventObject#getSource() */ public Object getOriginalObject() { // Compute the original for unit of work writes. if ((originalObject == null) && getSession().isUnitOfWork() && (getQuery() != null) && (getQuery().isObjectLevelModifyQuery())) { setOriginalObject(((UnitOfWorkImpl)getSession()).getOriginalVersionOfObject(getSource())); } return originalObject; }
/** * INTERNAL: */ void invokeMethod(String event, DescriptorEvent descriptorEvent) { List<Method> eventMethods = getEventMethods(event); if (eventMethods != null) { for (Method method : eventMethods) { Object[] objectList = { descriptorEvent.getSource() }; invokeMethod(method, getListener(descriptorEvent.getSession()), objectList, descriptorEvent); } } }
@Override public void postMerge(DescriptorEvent event) { if ((event.getChangeSet() != null) && event.getChangeSet().hasChanges()) { Object id = event.getChangeSet().getId(); CacheKey cacheKey = event.getChangeSet().getActiveCacheKey(); if (cacheKey == null) { cacheKey = event.getSession().getParent().getIdentityMapAccessorInstance().getIdentityMapManager().getCacheKeyForObject(id, descriptor.getJavaClass(), descriptor, false); } cacheKey.setTransactionId(event.getSession().getProperty(ORA_TRANSACTION_ID)); if (event.getChangeSet().isNew()) { AbstractRecord row = descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(id, event.getSession()); Object rowid = event.getSession().executeQuery(rowIdQuery, row); CacheId indexValue = new CacheId(new Object[]{rowid}); event.getSession().getParent().getIdentityMapAccessorInstance().getIdentityMapManager().putCacheKeyByIndex(index, indexValue, cacheKey, descriptor); } } } @Override
/** * PUBLIC: * Re-populate the database row with the values from the source object based upon the * attribute's mapping. Provided as a helper method for modifying the row during event * handling. */ public void applyAttributeValuesIntoRow(String attributeName) { ClassDescriptor descriptor = getSession().getDescriptor(getSource()); DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(attributeName); if (mapping == null) { throw ValidationException.missingMappingForAttribute(descriptor, attributeName, this.toString()); } if (getRecord() != null) { mapping.writeFromObjectIntoRow(getSource(), (AbstractRecord)getRecord(), getSession(), WriteType.UNDEFINED); } }
/** * PUBLIC: * Re-populate the database row with the values from the source object based upon the * attribute's mapping. Provided as a helper method for modifying the row during event * handling. */ public void applyAttributeValuesIntoRow(String attributeName) { ClassDescriptor descriptor = getSession().getDescriptor(getSource()); DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(attributeName); if (mapping == null) { throw ValidationException.missingMappingForAttribute(descriptor, attributeName, this.toString()); } if (getRecord() != null) { mapping.writeFromObjectIntoRow(getSource(), (AbstractRecord)getRecord(), getSession(), WriteType.UNDEFINED); } }
/** * PUBLIC: * Re-populate the database row with the values from the source object based upon the * attribute's mapping. Provided as a helper method for modifying the row during event * handling. */ public void applyAttributeValuesIntoRow(String attributeName) { ClassDescriptor descriptor = getSession().getDescriptor(getSource()); DatabaseMapping mapping = descriptor.getObjectBuilder().getMappingForAttributeName(attributeName); if (mapping == null) { throw ValidationException.missingMappingForAttribute(descriptor, attributeName, this.toString()); } if (getRecord() != null) { mapping.writeFromObjectIntoRow(getSource(), (AbstractRecord)getRecord(), getSession()); } }
@Override public void postMerge(DescriptorEvent event) { if ((event.getChangeSet() != null) && event.getChangeSet().hasChanges()) { Object id = event.getChangeSet().getId(); CacheKey cacheKey = event.getChangeSet().getActiveCacheKey(); if (cacheKey == null) { cacheKey = event.getSession().getParent().getIdentityMapAccessorInstance().getIdentityMapManager().getCacheKeyForObject(id, descriptor.getJavaClass(), descriptor, false); } cacheKey.setTransactionId(event.getSession().getProperty(ORA_TRANSACTION_ID)); if (event.getChangeSet().isNew()) { AbstractRecord row = descriptor.getObjectBuilder().buildRowFromPrimaryKeyValues(id, event.getSession()); Object rowid = event.getSession().executeQuery(rowIdQuery, row); CacheId indexValue = new CacheId(new Object[]{rowid}); event.getSession().getParent().getIdentityMapAccessorInstance().getIdentityMapManager().putCacheKeyByIndex(index, indexValue, cacheKey, descriptor); } } } @Override
/** * INTERNAL: * Handler for the descriptor post build event. * Convert the key and values to their appropriate type. */ public void postBuild(org.eclipse.persistence.descriptors.DescriptorEvent event) { setKey(event.getSession().getDatasourceLogin().getDatasourcePlatform().getConversionManager().convertObject(getKey(), getKeyType())); setValue(event.getSession().getDatasourceLogin().getDatasourcePlatform().getConversionManager().convertObject(getValue(), getValueType())); }
/** * INTERNAL: * Handler for the descriptor post build event. * Convert the key and values to their appropriate type. */ public void postBuild(org.eclipse.persistence.descriptors.DescriptorEvent event) { setKey(event.getSession().getDatasourceLogin().getDatasourcePlatform().getConversionManager().convertObject(getKey(), getKeyType())); setValue(event.getSession().getDatasourceLogin().getDatasourcePlatform().getConversionManager().convertObject(getValue(), getValueType())); }
@Override public void postUpdate(DescriptorEvent event) { String storeName = support.getStorageName(event.getSession()); Entity entity = (Entity) event.getSource(); if (entity instanceof SoftDelete && persistence.getTools().isDirty(entity, "deleteTs") && ((SoftDelete) entity).isDeleted()) { manager.fireListener(entity, EntityListenerType.AFTER_DELETE, storeName); } else { manager.fireListener(entity, EntityListenerType.AFTER_UPDATE, storeName); } }
/** * INTERNAL: * Handler for the descriptor post build event. * Convert the key and values to their appropriate type. */ public void postBuild(org.eclipse.persistence.descriptors.DescriptorEvent event) { setKey(event.getSession().getDatasourceLogin().getDatasourcePlatform().getConversionManager().convertObject(getKey(), getKeyType())); setValue(event.getSession().getDatasourceLogin().getDatasourcePlatform().getConversionManager().convertObject(getValue(), getValueType())); }
@Override public void postClone(DescriptorEvent event) { // in shared cache mode, postBuild event is missed, so we repeat it here if (event.getObject() instanceof BaseGenericIdEntity) { BaseEntityInternalAccess.setNew((BaseGenericIdEntity) event.getObject(), false); } if (event.getObject() instanceof FetchGroupTracker) { FetchGroupTracker entity = (FetchGroupTracker) event.getObject(); FetchGroup fetchGroup = entity._persistence_getFetchGroup(); if (fetchGroup != null && !(fetchGroup instanceof CubaEntityFetchGroup)) entity._persistence_setFetchGroup(new CubaEntityFetchGroup(fetchGroup)); } if (event.getObject() instanceof Entity) support.registerInstance((Entity) event.getObject(), event.getSession()); }