Hibernate ORM EventSource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Hibernate ORM EventSource class.

This code example shows how to use the following methods:generateEntityKey, getEntityPersister, getFactory, getPersistenceContext, forceFlush

7
CodeRank
This code example shows how to use the following methods:generateEntityKey, getEntityPersister, getFactory, getPersistenceContext, forceFlush

7
CodeRank
This code example shows how to use the following methods:getFactory, getPersistenceContext
    Object processCollection(Object collection, CollectionType collectionType) 
	throws HibernateException { 
 
		if ( collection!=null && (collection instanceof PersistentCollection) ) { 
 
			final SessionImplementor session = getSession(); 
			PersistentCollection coll = (PersistentCollection) collection; 
			if ( coll.setCurrentSession(session) ) { 
				reattachCollection( coll, collectionType ); 
			} 
			return null; 
 
		} 
		else { 
			return processArrayOrNewCollection(collection, collectionType); 
		} 
 
	} 
 
	final Object processArrayOrNewCollection(Object collection, CollectionType collectionType) 

6
CodeRank
This code example shows how to use the following methods:generateEntityKey, getEntityPersister, getFactory, getPersistenceContext, forceFlush

7
CodeRank
This code example shows how to use the following methods:generateEntityKey, getEntityPersister, getFactory, getPersistenceContext, forceFlush
	} 
 
	@Override 
	protected CascadingAction getCascadeAction() { 
		return EJB3CascadingAction.PERSIST_SKIPLAZY; 
	} 
} 

7
CodeRank
This code example shows how to use the following methods:getFactory, getPersistenceContext
		} 
		else { 
			if ( !isCollectionSnapshotValid(collection) ) {
				throw new HibernateException( "could not reassociate uninitialized transient collection" );
			} 
			CollectionPersister collectionPersister = getSession().getFactory()
					.getCollectionPersister( collection.getRole() );
			getSession().getPersistenceContext()
				.addUninitializedDetachedCollection( collectionPersister, collection );
		} 
	} 
 
} 
6
CodeRank
This code example shows how to use the following methods:getFactory, getPersistenceContext
	Object processCollection(Object collection, CollectionType type) throws HibernateException {
 
		if ( collection == CollectionType.UNFETCHED_COLLECTION ) {
			return null; 
		} 
 
		EventSource session = getSession();
		CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );
 
		final Serializable collectionKey = extractCollectionKeyFromOwner( persister );
		if ( collection!=null && (collection instanceof PersistentCollection) ) {
			PersistentCollection wrapper = (PersistentCollection) collection;
			if ( wrapper.setCurrentSession(session) ) {
				//a "detached" collection! 
				if ( !isOwnerUnchanged( wrapper, persister, collectionKey ) ) {
					// if the collection belonged to a different entity, 
					// clean up the existing state of the collection 
					removeCollection( persister, collectionKey, session );
				} 
				reattachCollection(wrapper, type);

6
CodeRank
This code example shows how to use the following methods:getFactory, getPersistenceContext
 
		if ( collection == CollectionType.UNFETCHED_COLLECTION ) {
			return null; 
		} 
 
		EventSource session = getSession();
		CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );
 
		if ( isUpdate ) {
			removeCollection( persister, extractCollectionKeyFromOwner( persister ), session );
		} 
		if ( collection != null && ( collection instanceof PersistentCollection ) ) {
			PersistentCollection wrapper = ( PersistentCollection ) collection;
			wrapper.setCurrentSession( session );
			if ( wrapper.wasInitialized() ) {
				session.getPersistenceContext().addNewCollection( persister, wrapper );
			} 
			else { 
				reattachCollection( wrapper, type );
			} 

6
CodeRank
This code example shows how to use the following methods:generateEntityKey, getEntityPersister, getFactory, getInterceptor, getPersistenceContext
	 * @throws HibernateException 
	 */ 
	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 ) ) { 

6
CodeRank
This code example shows how to use the following methods:getFactory, getPersistenceContext
		SessionImplementor session = getSession();
		CollectionPersister persister = session.getFactory().getCollectionPersister( type.getRole() );
 
		if ( collection == null ) { 
			//do nothing 
		} 
		else if ( collection instanceof PersistentCollection ) {
			PersistentCollection persistentCollection = ( PersistentCollection ) collection;
			if ( persistentCollection.setCurrentSession( session ) ) {
				if ( isOwnerUnchanged( persistentCollection, persister, extractCollectionKeyFromOwner( persister ) ) ) {
					// a "detached" collection that originally belonged to the same entity 
					if ( persistentCollection.isDirty() ) {
						throw new HibernateException( "reassociated object has dirty collection" );
					} 
					reattachCollection( persistentCollection, type );
				} 
				else { 
					// a "detached" collection that belonged to a different entity 
					throw new HibernateException( "reassociated object has dirty collection reference" );
				} 

6
CodeRank
See Code Examples for Hibernate ORM EventSource Methods: