Code example for SaveOrUpdateEvent

Methods: getEntity, getSession

0
public class DefaultUpdateEventListener extends DefaultSaveOrUpdateEventListener {
 
	protected Serializable performSaveOrUpdate(SaveOrUpdateEvent event) {
		// this implementation is supposed to tolerate incorrect unsaved-value 
		// mappings, for the purpose of backward-compatibility 
		EntityEntry entry = event.getSession().getPersistenceContext().getEntry( event.getEntity() );
		if ( entry!=null ) {
			if ( entry.getStatus()== Status.DELETED ) {
				throw new ObjectDeletedException( "deleted instance passed to update()", null, event.getEntityName() );
			} 
			else { 
				return entityIsPersistent(event);
			} 
		} 
		else { 
			entityIsDetached(event);
			return null; 
		} 
	} 
	 
	/**