Code example for PersistenceContext

Methods: addEntitycheckUniquenessgetEntryunproxyAndReassociate

0
	 */ 
	public void onDelete(DeleteEvent event, Set transientEntities) throws HibernateException { 
 
		final EventSource source = event.getSession(); 
 
		final PersistenceContext persistenceContext = source.getPersistenceContext(); 
		Object entity = persistenceContext.unproxyAndReassociate( event.getObject() ); 
 
		EntityEntry entityEntry = persistenceContext.getEntry( entity ); 
		final EntityPersister persister; 
		final Serializable id; 
		final Object version; 
 
		if ( entityEntry == null ) { 
            LOG.trace("Entity was not persistent in delete processing"); 
 
			persister = source.getEntityPersister( event.getEntityName(), entity ); 
 
			if ( ForeignKeys.isTransient( persister.getEntityName(), entity, null, source ) ) { 
				deleteTransientEntity( source, entity, event.isCascadeDeleteEnabled(), persister, transientEntities ); 
				// EARLY EXIT!!! 
				return; 
			} 
            performDetachedEntityDeletionCheck(event); 
 
			id = persister.getIdentifier( entity, source ); 
 
			if ( id == null ) { 
				throw new TransientObjectException( 
						"the detached instance passed to delete() had a null identifier" 
				); 
			} 
 
			final EntityKey key = source.generateEntityKey( id, persister ); 
 
			persistenceContext.checkUniqueness( key, entity ); 
 
			new OnUpdateVisitor( source, id, entity ).process( entity, persister ); 
 
			version = persister.getVersion( entity ); 
 
			entityEntry = persistenceContext.addEntity( 
					entity, 
					( persister.isMutable() ? Status.MANAGED : Status.READ_ONLY ), 
					persister.getPropertyValues( entity ), 
					key, 
Stop searching for code, let great code find you!  Add Codota to your java IDE