Code example for EventSource

Methods: generateEntityKeygetFactorygetPersistenceContext

0
		EventSource source = event.getSession(); 
		final Object object = event.getObject(); 
		final PersistenceContext persistenceContext = source.getPersistenceContext(); 
 
		if ( object instanceof HibernateProxy ) { 
			LazyInitializer li = ( (HibernateProxy) object ).getHibernateLazyInitializer(); 
			Serializable id = li.getIdentifier(); 
			EntityPersister persister = source.getFactory().getEntityPersister( li.getEntityName() ); 
			if ( id == null ) { 
				throw new IllegalArgumentException("null identifier"); 
			} 
 
			final EntityKey key = source.generateEntityKey( id, persister ); 
			persistenceContext.removeProxy( key ); 
 
			if ( !li.isUninitialized() ) { 
				final Object entity = persistenceContext.removeEntity( key ); 
				if ( entity != null ) { 
					EntityEntry e = event.getSession().getPersistenceContext().removeEntry( entity ); 
					doEvict( entity, key, e.getPersister(), event.getSession() ); 
				}