Java Code Examples for org.hibernate.sql.JoinType#NONE
The following examples show how to use
org.hibernate.sql.JoinType#NONE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JoinWalker.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Add on association (one-to-one, many-to-one, or a collection) to a list * of associations to be fetched by outerjoin (if necessary) */ private void addAssociationToJoinTreeIfNecessary( final AssociationType type, final String[] aliasedLhsColumns, final String alias, final PropertyPath path, int currentDepth, final JoinType joinType) throws MappingException { if ( joinType != JoinType.NONE ) { addAssociationToJoinTree( type, aliasedLhsColumns, alias, path, currentDepth, joinType ); } }
Example 2
Source File: JoinWalker.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Determine the appropriate associationType of join (if any) to use to fetch the * given association. * * @param associationType The association associationType. * @param config The metadata-defined fetch mode. * @param path The path to the association * @param lhsTable The owner table * @param lhsColumns The owner join columns * @param nullable Is the association nullable. * @param currentDepth Current join depth * @param cascadeStyle The metadata-defined cascade style. * * @return type of join to use ({@link org.hibernate.sql.JoinType#INNER_JOIN}, * {@link org.hibernate.sql.JoinType#LEFT_OUTER_JOIN}, or -1 to indicate no joining. * * @throws MappingException ?? */ protected JoinType getJoinType( AssociationType associationType, FetchMode config, PropertyPath path, String lhsTable, String[] lhsColumns, boolean nullable, int currentDepth, CascadeStyle cascadeStyle) throws MappingException { if ( !isJoinedFetchEnabled( associationType, config, cascadeStyle ) ) { return JoinType.NONE; } if ( isTooDeep( currentDepth ) || ( associationType.isCollectionType() && isTooManyCollections() ) ) { return JoinType.NONE; } if ( isDuplicateAssociation( lhsTable, lhsColumns, associationType ) ) { return JoinType.NONE; } return getJoinType( nullable, currentDepth ); }
Example 3
Source File: JoinWalker.java From lams with GNU General Public License v2.0 | 6 votes |
/** * Should we join this association? */ protected boolean isJoinable( final JoinType joinType, final Set visitedAssociationKeys, final String lhsTable, final String[] lhsColumnNames, final AssociationType type, final int depth) { if ( joinType == JoinType.NONE ) { return false; } if ( joinType == JoinType.INNER_JOIN ) { return true; } Integer maxFetchDepth = getFactory().getSessionFactoryOptions().getMaximumFetchDepth(); final boolean tooDeep = maxFetchDepth != null && depth >= maxFetchDepth; return !tooDeep && !isDuplicateAssociation( lhsTable, lhsColumnNames, type ); }
Example 4
Source File: EntityJoinWalker.java From lams with GNU General Public License v2.0 | 5 votes |
protected JoinType getJoinType( OuterJoinLoadable persister, PropertyPath path, int propertyNumber, AssociationType associationType, FetchMode metadataFetchMode, CascadeStyle metadataCascadeStyle, String lhsTable, String[] lhsColumns, boolean nullable, int currentDepth) throws MappingException { // NOTE : we override this form here specifically to account for // fetch profiles. // TODO : how to best handle criteria queries? if ( lockOptions.getLockMode().greaterThan( LockMode.READ ) ) { return JoinType.NONE; } if ( isTooDeep( currentDepth ) || ( associationType.isCollectionType() && isTooManyCollections() ) ) { return JoinType.NONE; } if ( !isJoinedFetchEnabledInMapping( metadataFetchMode, associationType ) && !isJoinFetchEnabledByProfile( persister, path, propertyNumber ) ) { return JoinType.NONE; } if ( isDuplicateAssociation( lhsTable, lhsColumns, associationType ) ) { return JoinType.NONE; } return getJoinType( nullable, currentDepth ); }
Example 5
Source File: AbstractEntityPersister.java From lams with GNU General Public License v2.0 | 5 votes |
protected JoinFragment createJoin( String name, boolean innerJoin, boolean includeSubclasses, Set<String> treatAsDeclarations) { // IMPL NOTE : all joins join to the pk of the driving table final String[] idCols = StringHelper.qualify( name, getIdentifierColumnNames() ); final JoinFragment join = getFactory().getDialect().createOuterJoinFragment(); final int tableSpan = getSubclassTableSpan(); // IMPL NOTE : notice that we skip the first table; it is the driving table! for ( int j = 1; j < tableSpan; j++ ) { final JoinType joinType = determineSubclassTableJoinType( j, innerJoin, includeSubclasses, treatAsDeclarations ); if ( joinType != null && joinType != JoinType.NONE ) { join.addJoin( getSubclassTableName( j ), generateTableAlias( name, j ), idCols, getSubclassTableKeyColumns( j ), joinType ); } } return join; }
Example 6
Source File: AbstractEntityPersister.java From lams with GNU General Public License v2.0 | 5 votes |
protected JoinType determineSubclassTableJoinType( int subclassTableNumber, boolean canInnerJoin, boolean includeSubclasses, Set<String> treatAsDeclarations) { if ( isClassOrSuperclassTable( subclassTableNumber ) ) { final boolean shouldInnerJoin = canInnerJoin && !isInverseTable( subclassTableNumber ) && !isNullableTable( subclassTableNumber ); // the table is either this persister's driving table or (one of) its super class persister's driving // tables which can be inner joined as long as the `shouldInnerJoin` condition resolves to true return shouldInnerJoin ? JoinType.INNER_JOIN : JoinType.LEFT_OUTER_JOIN; } // otherwise we have a subclass table and need to look a little deeper... // IMPL NOTE : By default includeSubclasses indicates that all subclasses should be joined and that each // subclass ought to be joined by outer-join. However, TREAT-AS always requires that an inner-join be used // so we give TREAT-AS higher precedence... if ( isSubclassTableIndicatedByTreatAsDeclarations( subclassTableNumber, treatAsDeclarations ) ) { return JoinType.INNER_JOIN; } if ( includeSubclasses && !isSubclassTableSequentialSelect( subclassTableNumber ) && !isSubclassTableLazy( subclassTableNumber ) ) { return JoinType.LEFT_OUTER_JOIN; } return JoinType.NONE; }
Example 7
Source File: FromParser.java From lams with GNU General Public License v2.0 | 5 votes |
public void start(QueryTranslatorImpl q) { entityName = null; collectionName = null; alias = null; afterIn = false; afterAs = false; afterClass = false; expectingJoin = false; expectingIn = false; expectingAs = false; memberDeclarations = false; expectingPathExpression = false; afterMemberDeclarations = false; joinType = JoinType.NONE; }
Example 8
Source File: CriteriaJoinWalker.java From lams with GNU General Public License v2.0 | 4 votes |
@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; }