FileDocCategorySizeDatePackage
OuterJoinableAssociation.javaAPI DocHibernate 3.2.54504Thu May 19 02:29:00 BST 2005org.hibernate.loader

OuterJoinableAssociation

public final class OuterJoinableAssociation extends Object

Fields Summary
private final org.hibernate.type.AssociationType
joinableType
private final org.hibernate.persister.entity.Joinable
joinable
private final String
lhsAlias
private final String[]
lhsColumns
private final String
rhsAlias
private final String[]
rhsColumns
private final int
joinType
private final String
on
private final Map
enabledFilters
Constructors Summary
public OuterJoinableAssociation(org.hibernate.type.AssociationType joinableType, String lhsAlias, String[] lhsColumns, String rhsAlias, int joinType, org.hibernate.engine.SessionFactoryImplementor factory, Map enabledFilters)

		this.joinableType = joinableType;
		this.lhsAlias = lhsAlias;
		this.lhsColumns = lhsColumns;
		this.rhsAlias = rhsAlias;
		this.joinType = joinType;
		this.joinable = joinableType.getAssociatedJoinable(factory);
		this.rhsColumns = JoinHelper.getRHSColumnNames(joinableType, factory);
		this.on = joinableType.getOnCondition(rhsAlias, factory, enabledFilters);
		this.enabledFilters = enabledFilters; // needed later for many-to-many/filter application
	
Methods Summary
public voidaddJoins(org.hibernate.sql.JoinFragment outerjoin)

		outerjoin.addJoin(
			joinable.getTableName(),
			rhsAlias,
			lhsColumns,
			rhsColumns,
			joinType,
			on
		);
		outerjoin.addJoins(
			joinable.fromJoinFragment(rhsAlias, false, true),
			joinable.whereJoinFragment(rhsAlias, false, true)
		);
	
public voidaddManyToManyJoin(org.hibernate.sql.JoinFragment outerjoin, org.hibernate.persister.collection.QueryableCollection collection)

		String manyToManyFilter = collection.getManyToManyFilterFragment( rhsAlias, enabledFilters );
		String condition = "".equals( manyToManyFilter )
				? on
				: "".equals( on )
						? manyToManyFilter
						: on + " and " + manyToManyFilter;
		outerjoin.addJoin(
		        joinable.getTableName(),
		        rhsAlias,
		        lhsColumns,
		        rhsColumns,
		        joinType,
		        condition
		);
		outerjoin.addJoins(
			joinable.fromJoinFragment(rhsAlias, false, true),
			joinable.whereJoinFragment(rhsAlias, false, true)
		);
	
public intgetJoinType()

		return joinType;
	
public org.hibernate.persister.entity.JoinablegetJoinable()

		return joinable;
	
public org.hibernate.type.AssociationTypegetJoinableType()

		return joinableType;
	
public intgetOwner(java.util.List associations)

		if ( isOneToOne() || isCollection() ) {
			return getPosition(lhsAlias, associations);
		}
		else {
			return -1;
		}
	
private static intgetPosition(java.lang.String lhsAlias, java.util.List associations)
Get the position of the join with the given alias in the list of joins

		int result = 0;
		for ( int i=0; i<associations.size(); i++ ) {
			OuterJoinableAssociation oj = (OuterJoinableAssociation) associations.get(i);
			if ( oj.getJoinable().consumesEntityAlias() /*|| oj.getJoinable().consumesCollectionAlias() */ ) {
				if ( oj.rhsAlias.equals(lhsAlias) ) return result;
				result++;
			}
		}
		return -1;
	
public java.lang.StringgetRHSAlias()

		return rhsAlias;
	
public java.lang.StringgetRHSUniqueKeyName()

		return joinableType.getRHSUniqueKeyPropertyName();
	
public booleanisCollection()

		return joinableType.isCollectionType();
	
public booleanisManyToManyWith(org.hibernate.loader.OuterJoinableAssociation other)

		if ( joinable.isCollection() ) {
			QueryableCollection persister = ( QueryableCollection ) joinable;
			if ( persister.isManyToMany() ) {
				return persister.getElementType() == other.getJoinableType();
			}
		}
		return false;
	
private booleanisOneToOne()

		if ( joinableType.isEntityType() )  {
			EntityType etype = (EntityType) joinableType;
			return etype.isOneToOne() /*&& etype.isReferenceToPrimaryKey()*/;
		}
		else {
			return false;
		}
			
	
public voidvalidateJoin(java.lang.String path)

		if (
			rhsColumns==null || 
			lhsColumns==null ||
			lhsColumns.length!=rhsColumns.length ||
			lhsColumns.length==0
		) {
			throw new MappingException("invalid join columns for association: " + path);
		}