use of org.hibernate.sql.JoinType in project hibernate-orm by hibernate.
the class FromElementFactory method createCollection.
public FromElement createCollection(QueryableCollection queryableCollection, String role, JoinType joinType, boolean fetchFlag, boolean indexed) throws SemanticException {
if (!collection) {
throw new IllegalStateException("FromElementFactory not initialized for collections!");
}
this.inElementsFunction = indexed;
FromElement elem;
this.queryableCollection = queryableCollection;
collectionType = queryableCollection.getCollectionType();
String roleAlias = fromClause.getAliasGenerator().createName(role);
// Correlated subqueries create 'special' implied from nodes
// because correlated subselects can't use an ANSI-style join
boolean explicitSubqueryFromElement = fromClause.isSubQuery() && !implied;
if (explicitSubqueryFromElement) {
String pathRoot = StringHelper.root(path);
FromElement origin = fromClause.getFromElement(pathRoot);
if (origin == null || origin.getFromClause() != fromClause) {
implied = true;
}
}
// super-duper-classic-parser-regression-testing-mojo-magic...
if (explicitSubqueryFromElement && DotNode.useThetaStyleImplicitJoins) {
implied = true;
}
Type elementType = queryableCollection.getElementType();
if (elementType.isEntityType()) {
// A collection of entities...
elem = createEntityAssociation(role, roleAlias, joinType);
} else if (elementType.isComponentType()) {
// A collection of components...
JoinSequence joinSequence = createJoinSequence(roleAlias, joinType);
elem = createCollectionJoin(joinSequence, roleAlias);
} else {
// A collection of scalar elements...
JoinSequence joinSequence = createJoinSequence(roleAlias, joinType);
elem = createCollectionJoin(joinSequence, roleAlias);
}
elem.setRole(role);
elem.setQueryableCollection(queryableCollection);
// Don't include sub-classes for implied collection joins or subquery joins.
if (implied) {
elem.setIncludeSubclasses(false);
}
if (explicitSubqueryFromElement) {
// Treat explict from elements in sub-queries properly.
elem.setInProjectionList(true);
}
if (fetchFlag) {
elem.setFetch(true);
}
return elem;
}
Aggregations