OuterJoinableAssociationpublic 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 void | addJoins(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 void | addManyToManyJoin(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 int | getJoinType()
return joinType;
| public org.hibernate.persister.entity.Joinable | getJoinable()
return joinable;
| public org.hibernate.type.AssociationType | getJoinableType()
return joinableType;
| public int | getOwner(java.util.List associations)
if ( isOneToOne() || isCollection() ) {
return getPosition(lhsAlias, associations);
}
else {
return -1;
}
| private static int | getPosition(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.String | getRHSAlias()
return rhsAlias;
| public java.lang.String | getRHSUniqueKeyName()
return joinableType.getRHSUniqueKeyPropertyName();
| public boolean | isCollection()
return joinableType.isCollectionType();
| public boolean | isManyToManyWith(org.hibernate.loader.OuterJoinableAssociation other)
if ( joinable.isCollection() ) {
QueryableCollection persister = ( QueryableCollection ) joinable;
if ( persister.isManyToMany() ) {
return persister.getElementType() == other.getJoinableType();
}
}
return false;
| private boolean | isOneToOne()
if ( joinableType.isEntityType() ) {
EntityType etype = (EntityType) joinableType;
return etype.isOneToOne() /*&& etype.isReferenceToPrimaryKey()*/;
}
else {
return false;
}
| public void | validateJoin(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);
}
|
|