/** * Add a join to this sequence * * @param associationType The type of the association representing the join * @param alias The RHS alias for the join * @param joinType The type of join (INNER, etc) * @param referencingKeys The LHS columns for the join condition * * @return The Join memento * * @throws MappingException Generally indicates a problem resolving the associationType to a {@link Joinable} */ public JoinSequence addJoin( AssociationType associationType, String alias, JoinType joinType, String[][] referencingKeys) throws MappingException { joins.add( new Join( factory, associationType, alias, joinType, referencingKeys ) ); return this; }
if ( joins.get( 0 ).getJoinType() != JoinType.INNER_JOIN ) { return true; Join join = joins.get( i ); if ( isAliasDereferenced( withClauseFragment, join.getAlias() ) || isSubclassAliasDereferenced( join, withClauseFragment ) ) { return true;
public JoinSequence copyForCollectionProperty() { JoinSequence copy = this.copy(); copy.joins.clear(); Iterator<Join> joinIterator = this.joins.iterator(); while ( joinIterator.hasNext() ) { Join join = joinIterator.next(); copy.addJoin( join.getAssociationType(), join.getAlias(), JoinType.INNER_JOIN, join.getLHSColumns() ); } return copy; }
String on = join.getAssociationType().getOnCondition( join.getAlias(), factory, enabledFilters ); String condition = null; if ( last != null && isManyToManyRoot( last ) && ( ( QueryableCollection ) last ).getElementType() == join.getAssociationType() ) { .getManyToManyFilterFragment( join.getAlias(), enabledFilters ); condition = "".equals( manyToManyFilter ) ? on if ( join.getAlias().equals( withClauseJoinAlias ) ) { condition += " and " + withClauseFragment; join.getJoinable().getTableName(), join.getAlias(), join.getLHSColumns(), JoinHelper.getRHSColumnNames( join.getAssociationType(), factory ), join.joinType, condition ); if (includeExtraJoins) { //TODO: not quite sure about the full implications of this! addExtraJoins( joinFragment, join.getAlias(), join.getJoinable(), join.joinType == JoinType.INNER_JOIN ); last = join.getJoinable();
String on = join.getAssociationType().getOnCondition( join.getAlias(), factory, enabledFilters ); String condition = null; if ( last != null && isManyToManyRoot( last ) && ( ( QueryableCollection ) last ).getElementType() == join.getAssociationType() ) { .getManyToManyFilterFragment( join.getAlias(), enabledFilters ); condition = "".equals( manyToManyFilter ) ? on if ( join.getAlias().equals( withClauseJoinAlias ) ) { condition += " and " + withClauseFragment; join.getJoinable().getTableName(), join.getAlias(), join.getLHSColumns(), JoinHelper.getRHSColumnNames( join.getAssociationType(), factory ), join.joinType, condition ); if (includeExtraJoins) { //TODO: not quite sure about the full implications of this! addExtraJoins( joinFragment, join.getAlias(), join.getJoinable(), join.joinType == JoinType.INNER_JOIN ); last = join.getJoinable();
/** * {@inheritDoc} */ public String[] toColumns(String alias, String propertyName) throws QueryException { validate( propertyName ); final String joinTableAlias = joinSequence.getFirstJoin().getAlias(); if ( CollectionPropertyNames.COLLECTION_INDEX.equals( propertyName ) ) { return queryableCollection.toColumns( joinTableAlias, propertyName ); } final String[] cols = queryableCollection.getIndexColumnNames( joinTableAlias ); if ( CollectionPropertyNames.COLLECTION_MIN_INDEX.equals( propertyName ) ) { if ( cols.length != 1 ) { throw new QueryException( "composite collection index in minIndex()" ); } return new String[] { "min(" + cols[0] + ')' }; } else { if ( cols.length != 1 ) { throw new QueryException( "composite collection index in maxIndex()" ); } return new String[] { "max(" + cols[0] + ')' }; } }
/** * {@inheritDoc} */ public String[] toColumns(String alias, String propertyName) throws QueryException { validate( propertyName ); final String joinTableAlias = joinSequence.getFirstJoin().getAlias(); if ( CollectionPropertyNames.COLLECTION_INDEX.equals( propertyName ) ) { return queryableCollection.toColumns( joinTableAlias, propertyName ); } final String[] cols = queryableCollection.getIndexColumnNames( joinTableAlias ); if ( CollectionPropertyNames.COLLECTION_MIN_INDEX.equals( propertyName ) ) { if ( cols.length != 1 ) { throw new QueryException( "composite collection index in minIndex()" ); } return new String[] { "min(" + cols[0] + ')' }; } else { if ( cols.length != 1 ) { throw new QueryException( "composite collection index in maxIndex()" ); } return new String[] { "max(" + cols[0] + ')' }; } }
public JoinSequence addJoin(AssociationType associationType, String alias, JoinType joinType, String[] referencingKey) throws MappingException { joins.add( new Join( associationType, alias, joinType, referencingKey ) ); return this; }
public JoinSequence addJoin(AssociationType associationType, String alias, JoinType joinType, String[] referencingKey) throws MappingException { joins.add( new Join( associationType, alias, joinType, referencingKey ) ); return this; }
joinFragment.addFromFragmentString( first.joinable.getTableName() ); joinFragment.addFromFragmentString( " " ); joinFragment.addFromFragmentString( first.getAlias() ); join.getJoinable().getTableName(), join.getAlias(), join.getLHSColumns(), JoinHelper.getRHSColumnNames( join.getAssociationType(), factory ), join.joinType ); join.getAlias(), join.getJoinable(), final String rhsAlias = first.getAlias(); final String[][] lhsColumns = first.getLHSColumns(); final String[] rhsColumns = JoinHelper.getRHSColumnNames( first.getAssociationType(), factory ); if ( lhsColumns.length > 1 ) { joinFragment.addFromFragmentString( "(" ); final String on = join.getAssociationType().getOnCondition( join.getAlias(), factory, enabledFilters, treatAsDeclarations ); String condition; if ( last != null && isManyToManyRoot( last ) && ((QueryableCollection) last).getElementType() == join.getAssociationType() ) { join.getAlias(), enabledFilters );
collectionFromElement.getJoinSequence().getFirstJoin().getJoinType(), joinColumns );
@Override public String[] toColumns(String alias, String propertyName) throws QueryException { validate( propertyName ); final String joinTableAlias = joinSequence.getFirstJoin().getAlias(); if ( CollectionPropertyNames.COLLECTION_INDEX.equals( propertyName ) ) { return queryableCollection.toColumns( joinTableAlias, propertyName ); } final String[] cols = queryableCollection.getIndexColumnNames( joinTableAlias ); if ( CollectionPropertyNames.COLLECTION_MIN_INDEX.equals( propertyName ) ) { if ( cols.length != 1 ) { throw new QueryException( "composite collection index in minIndex()" ); } return new String[] {"min(" + cols[0] + ')'}; } else { if ( cols.length != 1 ) { throw new QueryException( "composite collection index in maxIndex()" ); } return new String[] {"max(" + cols[0] + ')'}; } }
/** * Add a join to this sequence * * @param associationType The type of the association representing the join * @param alias The RHS alias for the join * @param joinType The type of join (INNER, etc) * @param referencingKey The LHS columns for the join condition * * @return The Join memento * * @throws MappingException Generally indicates a problem resolving the associationType to a {@link Joinable} */ public JoinSequence addJoin( AssociationType associationType, String alias, JoinType joinType, String[] referencingKey) throws MappingException { joins.add( new Join( factory, associationType, alias, joinType, new String[][] { referencingKey } ) ); return this; }
private boolean isSubclassAliasDereferenced(Join join, String withClauseFragment) { if ( join.getJoinable() instanceof AbstractEntityPersister ) { AbstractEntityPersister persister = (AbstractEntityPersister) join.getJoinable(); int subclassTableSpan = persister.getSubclassTableSpan(); for ( int j = 1; j < subclassTableSpan; j++ ) { String subclassAlias = AbstractEntityPersister.generateTableAlias( join.getAlias(), j ); if ( isAliasDereferenced( withClauseFragment, subclassAlias ) ) { return true; } } } return false; }