FileDocCategorySizeDatePackage
DefaultEntityAliases.javaAPI DocHibernate 3.2.53711Thu May 19 05:43:24 BST 2005org.hibernate.loader

DefaultEntityAliases

public class DefaultEntityAliases extends Object implements EntityAliases
EntityAliases which handles the logic of selecting user provided aliases (via return-property), before using the default aliases.
author
max

Fields Summary
private final String[]
suffixedKeyColumns
private final String[]
suffixedVersionColumn
private final String[]
suffixedPropertyColumns
private final String
suffixedDiscriminatorColumn
private final String
suffix
private final String
rowIdAlias
private final Map
userProvidedAliases
Constructors Summary
public DefaultEntityAliases(org.hibernate.persister.entity.Loadable persister, String suffix)

		this(CollectionHelper.EMPTY_MAP, persister, suffix);
	
public DefaultEntityAliases(Map userProvidedAliases, org.hibernate.persister.entity.Loadable persister, String suffix)
Calculate and cache select-clause suffixes.

param
map

		this.suffix = suffix;
		this.userProvidedAliases = userProvidedAliases;
		
		String[] keyColumnsCandidates = getUserProvidedAliases(
				persister.getIdentifierPropertyName(), 
				(String[]) null
			); 
		if (keyColumnsCandidates==null) {
			suffixedKeyColumns = getUserProvidedAliases(
					"id", 
					getIdentifierAliases(persister, suffix)
				);
		} 
		else {
			suffixedKeyColumns = keyColumnsCandidates;
		}
		intern(suffixedKeyColumns);
		
		suffixedPropertyColumns = getSuffixedPropertyAliases(persister);
		suffixedDiscriminatorColumn = getUserProvidedAlias(
				"class", 
				getDiscriminatorAlias(persister, suffix)
			);
		if ( persister.isVersioned() ) { 
			suffixedVersionColumn = suffixedPropertyColumns[ persister.getVersionProperty() ];
		}
		else {
			suffixedVersionColumn = null;
		}
		rowIdAlias = Loadable.ROWID_ALIAS + suffix; // TODO: not visible to the user!
	
Methods Summary
protected java.lang.StringgetDiscriminatorAlias(org.hibernate.persister.entity.Loadable persister, java.lang.String suffix)

		return persister.getDiscriminatorAlias(suffix);
	
protected java.lang.String[]getIdentifierAliases(org.hibernate.persister.entity.Loadable persister, java.lang.String suffix)

		return persister.getIdentifierAliases(suffix);
	
protected java.lang.String[]getPropertyAliases(org.hibernate.persister.entity.Loadable persister, int j)

		return persister.getPropertyAliases(suffix, j);
	
public java.lang.StringgetRowIdAlias()

		return rowIdAlias;
	
public java.lang.StringgetSuffixedDiscriminatorAlias()

		return suffixedDiscriminatorColumn;
	
public java.lang.String[]getSuffixedKeyAliases()

		return suffixedKeyColumns;
	
public java.lang.String[][]getSuffixedPropertyAliases()

		return suffixedPropertyColumns;
	
public java.lang.String[][]getSuffixedPropertyAliases(org.hibernate.persister.entity.Loadable persister)

		int size = persister.getPropertyNames().length;
		String[][] suffixedPropertyAliases = new String[size][];
		for ( int j = 0; j < size; j++ ) {
			suffixedPropertyAliases[j] = getUserProvidedAliases(
					persister.getPropertyNames()[j],
					getPropertyAliases(persister, j)
				);
			intern( suffixedPropertyAliases[j] );
		}			
		return suffixedPropertyAliases;
	
public java.lang.String[]getSuffixedVersionAliases()

		return suffixedVersionColumn;
	
private java.lang.StringgetUserProvidedAlias(java.lang.String propertyPath, java.lang.String defaultAlias)

		String[] columns = (String[]) userProvidedAliases.get(propertyPath);
		if (columns==null) {
			return defaultAlias;
		} 
		else {
			return columns[0];
		}
	
private java.lang.String[]getUserProvidedAliases(java.lang.String propertyPath, java.lang.String[] defaultAliases)

		String[] result = (String[]) userProvidedAliases.get(propertyPath);
		if (result==null) {
			return defaultAliases;			
		} 
		else {
			return result;
		}
	
private static voidintern(java.lang.String[] strings)

		for (int i=0; i<strings.length; i++ ) {
			strings[i] = strings[i].intern();
		}