public void add( Class entity, ClassLoaderService classLoaderService, EntityBinding binding ) { addCallback( entity, preCreates, PrePersist.class, classLoaderService, binding ); addCallback( entity, postCreates, PostPersist.class, classLoaderService, binding ); addCallback( entity, preRemoves, PreRemove.class, classLoaderService, binding ); addCallback( entity, postRemoves, PostRemove.class, classLoaderService, binding ); addCallback( entity, preUpdates, PreUpdate.class, classLoaderService, binding ); addCallback( entity, postUpdates, PostUpdate.class, classLoaderService, binding ); addCallback( entity, postLoads, PostLoad.class, classLoaderService, binding ); }
public boolean preCreate(Object bean) { return callback( preCreates.get( bean.getClass() ), bean ); }
@Override protected boolean invokeSaveLifecycle(Object entity, EntityPersister persister, EventSource source) { callbackHandler.preCreate( entity ); //always call the precreate event even if on safe vetoe it return super.invokeSaveLifecycle( entity, persister, source ); } }
public void configure() { EntityCallbackHandler callbackHandler = new EntityCallbackHandler(); callbackHandler.add( reflectionManager.classForName( clazz.getClassName(), this.getClass() ), reflectionManager );
public void onPostInsert(PostInsertEvent event) { Object entity = event.getEntity(); callbackHandler.postCreate( entity ); } }
public void onPostUpdate(PostUpdateEvent event) { Object entity = event.getEntity(); EntityEntry entry = (EntityEntry) event.getSession().getPersistenceContext().getEntityEntries().get( entity ); //mimic the preUpdate filter if ( Status.DELETED != entry.getStatus() ) { callbackHandler.postUpdate( entity ); } } }
@Override protected boolean invokeDeleteLifecycle(EventSource session, Object entity, EntityPersister persister) { callbackHandler.preRemove( entity ); return super.invokeDeleteLifecycle( session, entity, persister ); }
public void onPostDelete(PostDeleteEvent event) { Object entity = event.getEntity(); callbackHandler.postRemove( entity ); }
public void onPostLoad(PostLoadEvent event) { Object entity = event.getEntity(); callbackHandler.postLoad( entity ); }
@Override protected Serializable saveWithGeneratedId( Object entity, String entityName, Object anything, EventSource source, boolean requiresImmediateIdAccess) { callbackHandler.preCreate( entity ); return super.saveWithGeneratedId( entity, entityName, anything, source, requiresImmediateIdAccess ); } }
EntityCallbackHandler callbackHandler = new EntityCallbackHandler(); callbackHandler.add( reflectionManager.classForName( clazz.getClassName(), this.getClass() ), reflectionManager );
public void onPostInsert(PostInsertEvent event) { Object entity = event.getEntity(); callbackHandler.postCreate( entity ); } }
private void handlePostUpdate(Object entity, EventSource source) { EntityEntry entry = (EntityEntry) source.getPersistenceContext() .getEntityEntries().get(entity); // mimic the preUpdate filter if (Status.DELETED != entry.getStatus()) { callbackHandler.postUpdate(entity); } }
@Override protected boolean invokeDeleteLifecycle(EventSource session, Object entity, EntityPersister persister) { callbackHandler.preRemove( entity ); return super.invokeDeleteLifecycle( session, entity, persister ); }
public void onPostDelete(PostDeleteEvent event) { Object entity = event.getEntity(); callbackHandler.postRemove( entity ); }
public void onPostLoad(PostLoadEvent event) { Object entity = event.getEntity(); callbackHandler.postLoad( entity ); }
public boolean preUpdate(Object bean) { return callback( preUpdates.get( bean.getClass() ), bean ); }
@Override protected Serializable saveWithGeneratedId(Object entity, String entityName, Object anything, EventSource source, boolean requiresImmediateIdAccess) { callbackHandler.preCreate( entity ); return super.saveWithGeneratedId( entity, entityName, anything, source, requiresImmediateIdAccess ); } }
final EntityCallbackHandler callbackHandler = new EntityCallbackHandler(); Iterator classes = configuration.getClassMappings(); ReflectionManager reflectionManager = configuration.getReflectionManager(); callbackHandler.add( reflectionManager.classForName( clazz.getClassName(), this.getClass() ), reflectionManager );
public void add(XClass entity, ReflectionManager reflectionManager) { addCallback( entity, preCreates, PrePersist.class, reflectionManager ); addCallback( entity, postCreates, PostPersist.class, reflectionManager ); addCallback( entity, preRemoves, PreRemove.class, reflectionManager ); addCallback( entity, postRemoves, PostRemove.class, reflectionManager ); addCallback( entity, preUpdates, PreUpdate.class, reflectionManager ); addCallback( entity, postUpdates, PostUpdate.class, reflectionManager ); addCallback( entity, postLoads, PostLoad.class, reflectionManager ); }