Code example for SessionImplementor

Methods: generateEntityKeygetFactory

0
	 * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the 
	 * third argument (the entity associated with the key) if no proxy exists. Init 
	 * the proxy to the target implementation, if necessary. 
	 */ 
	public Object proxyFor(EntityPersister persister, EntityKey key, Object impl) 
	throws HibernateException { 
		if ( !persister.hasProxy() ) return impl; 
		Object proxy = proxiesByKey.get(key); 
		if ( proxy != null ) { 
			return narrowProxy(proxy, persister, key, impl); 
		} 
		else { 
			return impl; 
		} 
	} 
 
	/** 
	 * Return the existing proxy associated with the given <tt>EntityKey</tt>, or the 
	 * argument (the entity associated with the key) if no proxy exists. 
	 * (slower than the form above) 
	 */ 
	public Object proxyFor(Object impl) throws HibernateException { 
		EntityEntry e = getEntry(impl); 
		return proxyFor( e.getPersister(), e.getEntityKey(), impl ); 
	} 
 
	/** 
	 * Get the entity that owns this persistent collection 
	 */ 
	public Object getCollectionOwner(Serializable key, CollectionPersister collectionPersister) throws MappingException { 
		return getEntity( session.generateEntityKey( key, collectionPersister.getOwnerEntityPersister() ) ); 
	} 
 
	/** 
	 * Get the entity that owned this persistent collection when it was loaded 
	 * 
	 * @param collection The persistent collection 
	 * @return the owner, if its entity ID is available from the collection's loaded key 
	 * and the owner entity is in the persistence context; otherwise, returns null