private void addJoin(String name, AssociationType joinableType, String[] foreignKeyColumns) throws QueryException { try { joinSequence.addJoin( joinableType, name, joinType, foreignKeyColumns ); } catch ( MappingException me ) { throw new QueryException( me ); } }
private void addJoin(String name, AssociationType joinableType) throws QueryException { try { joinSequence.addJoin( joinableType, name, joinType, currentColumns() ); } catch ( MappingException me ) { throw new QueryException( me ); } }
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; }
/** * 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(); joinSequence.setUseThetaStyle( implicit ); // Implicit joins use theta style (WHERE pk = fk), explicit joins use JOIN (afterQuery from) joinSequence.addJoin( associationType, tableAlias, joinType, columns ); return joinSequence; }
/** * 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(); joinSequence.setUseThetaStyle( implicit ); // Implicit joins use theta style (WHERE pk = fk), explicit joins use JOIN (after from) joinSequence.addJoin( associationType, tableAlias, joinType, columns ); return joinSequence; }
&& fromElement.getOrigin().getWithClauseFragment() != null && fromElement.getOrigin().getWithClauseFragment().contains( fromElement.getTableAlias() ) ) { fromElement.getOrigin().getJoinSequence().addJoin( (ImpliedFromElement) fromElement );
joinSequence.addJoin( sfh.getElementAssociationType( collectionType ), tableAlias,
@Override protected AST createFromFilterElement(AST filterEntity, AST alias) throws SemanticException { FromElement fromElement = currentFromClause.addFromElement( filterEntity.getText(), alias ); FromClause fromClause = fromElement.getFromClause(); QueryableCollection persister = sessionFactoryHelper.getCollectionPersister( collectionFilterRole ); // Get the names of the columns used to link between the collection // owner and the collection elements. String[] keyColumnNames = persister.getKeyColumnNames(); String fkTableAlias = persister.isOneToMany() ? fromElement.getTableAlias() : fromClause.getAliasGenerator().createName( collectionFilterRole ); JoinSequence join = sessionFactoryHelper.createJoinSequence(); join.setRoot( persister, fkTableAlias ); if ( !persister.isOneToMany() ) { join.addJoin( (AssociationType) persister.getElementType(), fromElement.getTableAlias(), JoinType.INNER_JOIN, persister.getElementColumnNames( fkTableAlias ) ); } join.addCondition( fkTableAlias, keyColumnNames, " = ?" ); fromElement.setJoinSequence( join ); fromElement.setFilter( true ); LOG.debug( "createFromFilterElement() : processed filter FROM element." ); return fromElement; }
join.addJoin( (AssociationType) persister.getElementType(), elementName,
private void addJoin(String name, AssociationType joinableType, String[] foreignKeyColumns) throws QueryException { try { joinSequence.addJoin( joinableType, name, joinType, foreignKeyColumns ); } catch ( MappingException me ) { throw new QueryException( me ); } }
private void addJoin(String name, AssociationType joinableType, String[] foreignKeyColumns) throws QueryException { try { joinSequence.addJoin( joinableType, name, joinType, foreignKeyColumns ); } catch ( MappingException me ) { throw new QueryException( me ); } }
private void addJoin(String name, AssociationType joinableType) throws QueryException { try { joinSequence.addJoin( joinableType, name, joinType, currentColumns() ); } catch ( MappingException me ) { throw new QueryException( me ); } }
private void addJoin(String name, AssociationType joinableType) throws QueryException { try { joinSequence.addJoin( joinableType, name, joinType, currentColumns() ); } catch ( MappingException me ) { throw new QueryException( me ); } }
/** * 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(); joinSequence.setUseThetaStyle( implicit ); // Implicit joins use theta style (WHERE pk = fk), explicit joins use JOIN (after from) joinSequence.addJoin( associationType, tableAlias, joinType, columns ); return joinSequence; }
/** * 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(); joinSequence.setUseThetaStyle( implicit ); // Implicit joins use theta style (WHERE pk = fk), explicit joins use JOIN (after from) joinSequence.addJoin( associationType, tableAlias, joinType, columns ); return joinSequence; }
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; }
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; }
@Override protected AST createFromFilterElement(AST filterEntity, AST alias) throws SemanticException { FromElement fromElement = currentFromClause.addFromElement( filterEntity.getText(), alias ); FromClause fromClause = fromElement.getFromClause(); QueryableCollection persister = sessionFactoryHelper.getCollectionPersister( collectionFilterRole ); // Get the names of the columns used to link between the collection // owner and the collection elements. String[] keyColumnNames = persister.getKeyColumnNames(); String fkTableAlias = persister.isOneToMany() ? fromElement.getTableAlias() : fromClause.getAliasGenerator().createName( collectionFilterRole ); JoinSequence join = sessionFactoryHelper.createJoinSequence(); join.setRoot( persister, fkTableAlias ); if ( !persister.isOneToMany() ) { join.addJoin( ( AssociationType ) persister.getElementType(), fromElement.getTableAlias(), JoinType.INNER_JOIN, persister.getElementColumnNames( fkTableAlias ) ); } join.addCondition( fkTableAlias, keyColumnNames, " = ?" ); fromElement.setJoinSequence( join ); fromElement.setFilter( true ); LOG.debug("createFromFilterElement() : processed filter FROM element."); return fromElement; }
@Override protected AST createFromFilterElement(AST filterEntity, AST alias) throws SemanticException { FromElement fromElement = currentFromClause.addFromElement( filterEntity.getText(), alias ); FromClause fromClause = fromElement.getFromClause(); QueryableCollection persister = sessionFactoryHelper.getCollectionPersister( collectionFilterRole ); // Get the names of the columns used to link between the collection // owner and the collection elements. String[] keyColumnNames = persister.getKeyColumnNames(); String fkTableAlias = persister.isOneToMany() ? fromElement.getTableAlias() : fromClause.getAliasGenerator().createName( collectionFilterRole ); JoinSequence join = sessionFactoryHelper.createJoinSequence(); join.setRoot( persister, fkTableAlias ); if ( !persister.isOneToMany() ) { join.addJoin( ( AssociationType ) persister.getElementType(), fromElement.getTableAlias(), JoinType.INNER_JOIN, persister.getElementColumnNames( fkTableAlias ) ); } join.addCondition( fkTableAlias, keyColumnNames, " = ?" ); fromElement.setJoinSequence( join ); fromElement.setFilter( true ); LOG.debug("createFromFilterElement() : processed filter FROM element."); return fromElement; }
join.addJoin( ( AssociationType ) persister.getElementType(), elementName, JoinType.INNER_JOIN,