FileDocCategorySizeDatePackage
CollectionElementLoader.javaAPI DocHibernate 3.2.52781Thu Mar 16 07:14:48 GMT 2006org.hibernate.loader.entity

CollectionElementLoader

public class CollectionElementLoader extends org.hibernate.loader.OuterJoinLoader
author
Gavin King

Fields Summary
private static final Log
log
private final org.hibernate.persister.entity.OuterJoinLoadable
persister
private final org.hibernate.type.Type
keyType
private final org.hibernate.type.Type
indexType
private final String
entityName
Constructors Summary
public CollectionElementLoader(org.hibernate.persister.collection.QueryableCollection collectionPersister, org.hibernate.engine.SessionFactoryImplementor factory, Map enabledFilters)


	 
			 
			  
			  
	  
		super(factory, enabledFilters);

		this.keyType = collectionPersister.getKeyType();
		this.indexType = collectionPersister.getIndexType();
		this.persister = (OuterJoinLoadable) collectionPersister.getElementPersister();
		this.entityName = persister.getEntityName();
		
		JoinWalker walker = new EntityJoinWalker(
				persister, 
				ArrayHelper.join( 
						collectionPersister.getKeyColumnNames(), 
						collectionPersister.getIndexColumnNames()
					),
				1, 
				LockMode.NONE, 
				factory, 
				enabledFilters
			);
		initFromWalker( walker );

		postInstantiate();
		
		log.debug( "Static select for entity " + entityName + ": " + getSQLString() );

	
Methods Summary
protected java.lang.ObjectgetResultColumnOrRow(java.lang.Object[] row, org.hibernate.transform.ResultTransformer transformer, java.sql.ResultSet rs, org.hibernate.engine.SessionImplementor session)

		return row[row.length-1];
	
protected booleanisSingleRowLoader()

		return true;
	
public java.lang.ObjectloadElement(org.hibernate.engine.SessionImplementor session, java.lang.Object key, java.lang.Object index)

		
		List list = loadEntity(
				session, 
				key,
				index,
				keyType, 
				indexType,
				persister
			);
		
		if ( list.size()==1 ) {
			return list.get(0);
		}
		else if ( list.size()==0 ) {
			return null;
		}
		else {
			if ( getCollectionOwners()!=null ) {
				return list.get(0);
			}
			else {
				throw new HibernateException("More than one row was found");
			}
		}