Code example for EventSource

Methods: getFactorygetPersistenceContext

0
    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) 
	throws HibernateException { 
 
		final SessionImplementor session = getSession(); 
 
		if (collection==null) { 
			//do nothing 
			return null; 
		} 
		else { 
			CollectionPersister persister = session.getFactory().getCollectionPersister( collectionType.getRole() ); 
 
			final PersistenceContext persistenceContext = session.getPersistenceContext(); 
			//TODO: move into collection type, so we can use polymorphism! 
			if ( collectionType.hasHolder() ) { 
 
				if (collection==CollectionType.UNFETCHED_COLLECTION) return null; 
 
				PersistentCollection ah = persistenceContext.getCollectionHolder(collection); 
				if (ah==null) { 
					ah = collectionType.wrap(session, collection); 
					persistenceContext.addNewCollection( persister, ah );