org.hibernate.event.spi.PostDeleteEvent Java Examples
The following examples show how to use
org.hibernate.event.spi.PostDeleteEvent.
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: EntityDeleteAction.java From lams with GNU General Public License v2.0 | 6 votes |
private void postDelete() { final EventListenerGroup<PostDeleteEventListener> listenerGroup = listenerGroup( EventType.POST_DELETE ); if ( listenerGroup.isEmpty() ) { return; } final PostDeleteEvent event = new PostDeleteEvent( getInstance(), getId(), state, getPersister(), eventSource() ); for ( PostDeleteEventListener listener : listenerGroup.listeners() ) { listener.onPostDelete( event ); } }
Example #2
Source File: EntityCrudEventListener.java From mojito with Apache License 2.0 | 6 votes |
@Override public void onPostDelete(PostDeleteEvent event) { Repository repository = null; Object entity = event.getEntity(); if (entity instanceof RepositoryLocale) { RepositoryLocale repositoryLocale = (RepositoryLocale) entity; repository = repositoryLocale.getRepository(); logger.debug("Repository statistics is outdated because locale is deleted"); } else if (entity instanceof TMTextUnitCurrentVariant) { TMTextUnitCurrentVariant tmTextUnitCurrentVariant = (TMTextUnitCurrentVariant) entity; repository = tmTextUnitCurrentVariant.getTmTextUnit().getAsset().getRepository(); logger.debug("Repository statistics is outdated because translation is deleted"); } setRepositoryStatistisOutOfDate(repository); }
Example #3
Source File: EntityDeleteAction.java From lams with GNU General Public License v2.0 | 5 votes |
private void postCommitDelete(boolean success) { final EventListenerGroup<PostDeleteEventListener> listenerGroup = listenerGroup( EventType.POST_COMMIT_DELETE ); if ( listenerGroup.isEmpty() ) { return; } final PostDeleteEvent event = new PostDeleteEvent( getInstance(), getId(), state, getPersister(), eventSource() ); for ( PostDeleteEventListener listener : listenerGroup.listeners() ) { if ( PostCommitDeleteEventListener.class.isInstance( listener ) ) { if ( success ) { listener.onPostDelete( event ); } else { ((PostCommitDeleteEventListener) listener).onPostDeleteCommitFailed( event ); } } else { //default to the legacy implementation that always fires the event listener.onPostDelete( event ); } } }
Example #4
Source File: DeletedObjectPostDeleteEventListener.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onPostDelete( PostDeleteEvent event ) { if ( IdentifiableObject.class.isInstance( event.getEntity() ) && MetadataObject.class.isInstance( event.getEntity() ) && !EmbeddedObject.class.isInstance( event.getEntity() ) ) { IdentifiableObject identifiableObject = (IdentifiableObject) event.getEntity(); DeletedObject deletedObject = new DeletedObject( identifiableObject ); deletedObject.setDeletedBy( getUsername() ); StatelessSession session = event.getPersister().getFactory().openStatelessSession(); session.beginTransaction(); try { session.insert( deletedObject ); session.getTransaction().commit(); } catch ( Exception ex ) { log.error( "Failed to save DeletedObject: "+ deletedObject ); session.getTransaction().rollback(); } finally { session.close(); } } }
Example #5
Source File: PostDeleteAuditListener.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Override public void onPostDelete( PostDeleteEvent postDeleteEvent ) { Object entity = postDeleteEvent.getEntity(); getAuditable( entity, "delete" ).ifPresent( auditable -> auditManager.send( Audit.builder() .auditType( getAuditType() ) .auditScope( auditable.scope() ) .createdAt( LocalDateTime.now() ) .createdBy( getCreatedBy() ) .object( entity ) .auditableEntity( new AuditableEntity( entity ) ) .build() ) ); }
Example #6
Source File: CollectionCacheInvalidator.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void onPostDelete(PostDeleteEvent event) { evictCache( event.getEntity(), event.getPersister(), event.getSession(), null ); }
Example #7
Source File: PostDeleteEventListenerStandardImpl.java From lams with GNU General Public License v2.0 | 4 votes |
public void onPostDelete(PostDeleteEvent event) { Object entity = event.getEntity(); callbackRegistry.postRemove( entity ); }
Example #8
Source File: EntityCrudEventListener.java From mojito with Apache License 2.0 | 4 votes |
@Override public void onPostDeleteCommitFailed(PostDeleteEvent pde) { }
Example #9
Source File: ClosureEventTriggeringInterceptor.java From gorm-hibernate5 with Apache License 2.0 | 4 votes |
public void onPostDelete(PostDeleteEvent hibernateEvent) { org.grails.datastore.mapping.engine.event.PostDeleteEvent grailsEvent = new org.grails.datastore.mapping.engine.event.PostDeleteEvent( this.datastore, hibernateEvent.getEntity()); publishEvent(hibernateEvent, grailsEvent); }
Example #10
Source File: DeletedObjectPostDeleteEventListener.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onPostDeleteCommitFailed( PostDeleteEvent event ) { log.debug( "onPostDeleteCommitFailed: " + event ); }
Example #11
Source File: PostDeleteAuditListener.java From dhis2-core with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Override public void onPostDeleteCommitFailed( PostDeleteEvent event ) { log.warn( "onPostDeleteCommitFailed: " + event ); }