use of org.hibernate.engine.internal.JoinSequence in project hibernate-orm by hibernate.
the class FromElementFactory method createCollectionElementsJoin.
FromElement createCollectionElementsJoin(QueryableCollection queryableCollection, String collectionName) throws SemanticException {
JoinSequence collectionJoinSequence = fromClause.getSessionFactoryHelper().createCollectionJoinSequence(queryableCollection, collectionName);
this.queryableCollection = queryableCollection;
return createCollectionJoin(collectionJoinSequence, null);
}
use of org.hibernate.engine.internal.JoinSequence in project hibernate-orm by hibernate.
the class FromElementFactory method createManyToMany.
private FromElement createManyToMany(String role, String associatedEntityName, String roleAlias, Queryable entityPersister, EntityType type, JoinType joinType) throws SemanticException {
FromElement elem;
SessionFactoryHelper sfh = fromClause.getSessionFactoryHelper();
if (inElementsFunction) /*implied*/
{
// For implied many-to-many, just add the end join.
JoinSequence joinSequence = createJoinSequence(roleAlias, joinType);
elem = createJoin(associatedEntityName, roleAlias, joinSequence, type, true);
} else {
// For an explicit many-to-many relationship, add a second join from the intermediate
// (many-to-many) table to the destination table. Also, make sure that the from element's
// idea of the destination is the destination table.
String tableAlias = fromClause.getAliasGenerator().createName(entityPersister.getEntityName());
String[] secondJoinColumns = sfh.getCollectionElementColumns(role, roleAlias);
// Add the second join, the one that ends in the destination table.
JoinSequence joinSequence = createJoinSequence(roleAlias, joinType);
joinSequence.addJoin(sfh.getElementAssociationType(collectionType), tableAlias, joinType, secondJoinColumns);
elem = createJoin(associatedEntityName, tableAlias, joinSequence, type, false);
elem.setUseFromFragment(true);
}
return elem;
}
use of org.hibernate.engine.internal.JoinSequence in project hibernate-orm by hibernate.
the class FromElementType method getJoinSequence.
public JoinSequence getJoinSequence() {
if (joinSequence != null) {
return joinSequence;
}
// Class names in the FROM clause result in a JoinSequence (the old FromParser does this).
if (persister instanceof Joinable) {
Joinable joinable = (Joinable) persister;
final JoinSequence joinSequence = fromElement.getSessionFactoryHelper().createJoinSequence().setRoot(joinable, getTableAlias());
joinSequence.applyTreatAsDeclarations(treatAsDeclarations);
return joinSequence;
} else {
// TODO: Should this really return null? If not, figure out something better to do here.
return null;
}
}
use of org.hibernate.engine.internal.JoinSequence in project hibernate-orm by hibernate.
the class SessionFactoryHelper method createJoinSequence.
/**
* Generate a join sequence representing the given association type.
*
* @param implicit Should implicit joins (theta-style) or explicit joins (ANSI-style) be rendered
* @param associationType The type representing the thing to be joined into.
* @param tableAlias The table alias to use in qualifying the join conditions
* @param joinType The type of join to render (inner, outer, etc); see {@link org.hibernate.sql.JoinFragment}
* @param columns The columns making up the condition of the join.
*
* @return The generated join sequence.
*/
public JoinSequence createJoinSequence(boolean implicit, AssociationType associationType, String tableAlias, JoinType joinType, String[] columns) {
JoinSequence joinSequence = createJoinSequence();
// Implicit joins use theta style (WHERE pk = fk), explicit joins use JOIN (after from)
joinSequence.setUseThetaStyle(implicit);
joinSequence.addJoin(associationType, tableAlias, joinType, columns);
return joinSequence;
}
use of org.hibernate.engine.internal.JoinSequence in project hibernate-orm by hibernate.
the class SessionFactoryHelper method createCollectionJoinSequence.
/**
* Create a join sequence rooted at the given collection.
*
* @param collPersister The persister for the collection at which the join should be rooted.
* @param collectionName The alias to use for qualifying column references.
*
* @return The generated join sequence.
*/
public JoinSequence createCollectionJoinSequence(QueryableCollection collPersister, String collectionName) {
JoinSequence joinSequence = createJoinSequence();
joinSequence.setRoot(collPersister, collectionName);
// TODO: figure out how this should be set.
joinSequence.setUseThetaStyle(true);
// joinSequence = joinSequence.getFromPart(); // Emulate the old addFromOnly behavior.
return joinSequence;
}
Aggregations