FileDocCategorySizeDatePackage
BasicLoader.javaAPI DocHibernate 3.2.52819Thu May 04 06:57:58 BST 2006org.hibernate.loader

BasicLoader

public abstract class BasicLoader extends Loader
Uses the default mapping from property to result set column alias defined by the entities' persisters. Used when Hibernate is generating result set column aliases.
author
Gavin King

Fields Summary
protected static final String[]
NO_SUFFIX
private EntityAliases[]
descriptors
private CollectionAliases[]
collectionDescriptors
Constructors Summary
public BasicLoader(org.hibernate.engine.SessionFactoryImplementor factory)


	   
		super(factory);
	
Methods Summary
public static java.lang.String[]generateSuffixes(int length)
Utility method that generates 0_, 1_ suffixes. Subclasses don't necessarily need to use this algorithm, but it is intended that they will in most cases.

		return generateSuffixes( 0, length );
	
public static java.lang.String[]generateSuffixes(int seed, int length)

		if ( length == 0 ) return NO_SUFFIX;

		String[] suffixes = new String[length];
		for ( int i = 0; i < length; i++ ) {
			suffixes[i] = Integer.toString( i + seed ) + "_";
		}
		return suffixes;
	
protected final CollectionAliases[]getCollectionAliases()

		return collectionDescriptors;
	
protected abstract java.lang.String[]getCollectionSuffixes()

protected final EntityAliases[]getEntityAliases()

		return descriptors;
	
protected abstract java.lang.String[]getSuffixes()

private booleanisBag(org.hibernate.persister.collection.CollectionPersister collectionPersister)

		return collectionPersister.getCollectionType().getClass().isAssignableFrom( BagType.class );
	
protected voidpostInstantiate()

		Loadable[] persisters = getEntityPersisters();
		String[] suffixes = getSuffixes();
		descriptors = new EntityAliases[persisters.length];
		for ( int i=0; i<descriptors.length; i++ ) {
			descriptors[i] = new DefaultEntityAliases( persisters[i], suffixes[i] );
		}

		CollectionPersister[] collectionPersisters = getCollectionPersisters();
		int bagCount = 0;
		if ( collectionPersisters != null ) {
			String[] collectionSuffixes = getCollectionSuffixes();
			collectionDescriptors = new CollectionAliases[collectionPersisters.length];
			for ( int i = 0; i < collectionPersisters.length; i++ ) {
				if ( isBag( collectionPersisters[i] ) ) {
					bagCount++;
				}
				collectionDescriptors[i] = new GeneratedCollectionAliases(
						collectionPersisters[i],
						collectionSuffixes[i]
					);
			}
		}
		else {
			collectionDescriptors = null;
		}
		if ( bagCount > 1 ) {
			throw new HibernateException( "cannot simultaneously fetch multiple bags" );
		}