use of org.hibernate.FetchMode in project hibernate-orm by hibernate.
the class CriteriaJoinWalker method getJoinType.
@Override
protected JoinType getJoinType(OuterJoinLoadable persister, final PropertyPath path, int propertyNumber, AssociationType associationType, FetchMode metadataFetchMode, CascadeStyle metadataCascadeStyle, String lhsTable, String[] lhsColumns, final boolean nullable, final int currentDepth) throws MappingException {
final JoinType resolvedJoinType;
if (translator.isJoin(path.getFullPath())) {
resolvedJoinType = translator.getJoinType(path.getFullPath());
} else {
if (translator.hasProjection()) {
resolvedJoinType = JoinType.NONE;
} else {
String fullPathWithAlias = path.getFullPath();
String rootAlias = translator.getRootCriteria().getAlias();
String rootAliasPathPrefix = rootAlias + ".";
if (rootAlias != null && !fullPathWithAlias.startsWith(rootAliasPathPrefix)) {
fullPathWithAlias = rootAliasPathPrefix + fullPathWithAlias;
}
FetchMode fetchMode = translator.getRootCriteria().getFetchMode(fullPathWithAlias);
if (isDefaultFetchMode(fetchMode)) {
if (persister != null) {
if (isJoinFetchEnabledByProfile(persister, path, propertyNumber)) {
if (isDuplicateAssociation(lhsTable, lhsColumns, associationType)) {
resolvedJoinType = JoinType.NONE;
} else if (isTooDeep(currentDepth) || (associationType.isCollectionType() && isTooManyCollections())) {
resolvedJoinType = JoinType.NONE;
} else {
resolvedJoinType = getJoinType(nullable, currentDepth);
}
} else {
resolvedJoinType = super.getJoinType(persister, path, propertyNumber, associationType, metadataFetchMode, metadataCascadeStyle, lhsTable, lhsColumns, nullable, currentDepth);
}
} else {
resolvedJoinType = super.getJoinType(associationType, metadataFetchMode, path, lhsTable, lhsColumns, nullable, currentDepth, metadataCascadeStyle);
}
} else {
if (fetchMode == FetchMode.JOIN) {
isDuplicateAssociation(lhsTable, lhsColumns, associationType);
// deliberately ignore return value!
resolvedJoinType = getJoinType(nullable, currentDepth);
} else {
resolvedJoinType = JoinType.NONE;
}
}
}
}
return resolvedJoinType;
}