Code example for SessionImplementor

Methods: getFactory

0
	 */ 
	private void addCollection(PersistentCollection coll, CollectionEntry entry, Serializable key) { 
		collectionEntries.put( coll, entry ); 
		CollectionKey collectionKey = new CollectionKey( entry.getLoadedPersister(), key ); 
		PersistentCollection old = ( PersistentCollection ) collectionsByKey.put( collectionKey, coll ); 
		if ( old != null ) { 
			if ( old == coll ) { 
				throw new AssertionFailure("bug adding collection twice"); 
			} 
			// or should it actually throw an exception? 
			old.unsetSession( session ); 
			collectionEntries.remove( old ); 
			// watch out for a case where old is still referenced 
			// somewhere in the object graph! (which is a user error) 
		} 
	} 
 
	/** 
	 * Add a collection to the cache, creating a new collection entry for it 
	 * 
	 * @param collection The collection for which we are adding an entry. 
	 * @param persister The collection persister 
	 */ 
	private void addCollection(PersistentCollection collection, CollectionPersister persister) { 
		CollectionEntry ce = new CollectionEntry( persister, collection ); 
		collectionEntries.put( collection, ce ); 
	} 
 
	/** 
	 * add an (initialized) collection that was created by another session and passed 
	 * into update() (ie. one with a snapshot and existing state on the database) 
	 */ 
	public void addInitializedDetachedCollection(CollectionPersister collectionPersister, PersistentCollection collection) 
	throws HibernateException { 
		if ( collection.isUnreferenced() ) { 
			//treat it just like a new collection 
			addCollection( collection, collectionPersister );