/** * Create a join sequence rooted at the given collection. * * @param collPersister The persister for the collection at which the join should be rooted. * @param collectionName The alias to use for qualifying column references. * * @return The generated join sequence. */ public JoinSequence createCollectionJoinSequence(QueryableCollection collPersister, String collectionName) { JoinSequence joinSequence = createJoinSequence(); joinSequence.setRoot( collPersister, collectionName ); joinSequence.setUseThetaStyle( true ); // TODO: figure out how this should be set. /////////////////////////////////////////////////////////////////////////////// // This was the reason for failures regarding INDEX_OP and subclass joins on // theta-join dialects; not sure what behavior we were trying to emulate ;) // joinSequence = joinSequence.getFromPart(); // Emulate the old addFromOnly behavior. return joinSequence; }
void addFromClass(String name, Queryable classPersister) throws QueryException { JoinSequence joinSequence = new JoinSequence( getFactory() ) .setRoot( classPersister, name ); //crossJoins.add(name); addFrom( name, classPersister.getEntityName(), joinSequence ); }
public JoinSequence getJoinSequence() { if ( joinSequence != null ) { return joinSequence; } // Class names in the FROM clause result in a JoinSequence (the old FromParser does this). if ( persister instanceof Joinable ) { Joinable joinable = (Joinable) persister; final JoinSequence joinSequence = fromElement.getSessionFactoryHelper().createJoinSequence().setRoot( joinable, getTableAlias() ); joinSequence.applyTreatAsDeclarations( treatAsDeclarations ); return joinSequence; } else { // TODO: Should this really return null? If not, figure out something better to do here. return null; } }
private void prepareForIndex(QueryTranslatorImpl q) throws QueryException { QueryableCollection collPersister = q.getCollectionPersister( collectionRole ); if ( !collPersister.hasIndex() ) { throw new QueryException( "unindexed collection before []: " + path ); } String[] indexCols = collPersister.getIndexColumnNames(); if ( indexCols.length != 1 ) { throw new QueryException( "composite-index appears in []: " + path ); } //String[] keyCols = collPersister.getKeyColumnNames(); JoinSequence fromJoins = new JoinSequence( q.getFactory() ) .setUseThetaStyle( useThetaStyleJoin ) .setRoot( collPersister, collectionName ) .setNext( joinSequence.copy() ); if ( !continuation ) { addJoin( collectionName, collPersister.getCollectionType() ); } joinSequence.addCondition( collectionName + '.' + indexCols[0] + " = " ); //TODO: get SQL rendering out of here CollectionElement elem = new CollectionElement(); elem.elementColumns = collPersister.getElementColumnNames(collectionName); elem.elementType = collPersister.getElementType(); elem.isOneToMany = collPersister.isOneToMany(); elem.alias = collectionName; elem.joinSequence = joinSequence; collectionElements.addLast( elem ); setExpectingCollectionIndex(); q.addCollection( collectionName, collectionRole ); q.addFromJoinOnly( collectionName, fromJoins ); }
@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; }
elementName : createNameForCollection( collectionRole ); join.setRoot( persister, collectionName ); if ( !persister.isOneToMany() ) {
/** * Create a join sequence rooted at the given collection. * * @param collPersister The persister for the collection at which the join should be rooted. * @param collectionName The alias to use for qualifying column references. * @return The generated join sequence. */ public JoinSequence createCollectionJoinSequence(QueryableCollection collPersister, String collectionName) { JoinSequence joinSequence = createJoinSequence(); joinSequence.setRoot( collPersister, collectionName ); joinSequence.setUseThetaStyle( true ); // TODO: figure out how this should be set. /////////////////////////////////////////////////////////////////////////////// // This was the reason for failures regarding INDEX_OP and subclass joins on // theta-join dialects; not sure what behavior we were trying to emulate ;) // joinSequence = joinSequence.getFromPart(); // Emulate the old addFromOnly behavior. return joinSequence; }
/** * Create a join sequence rooted at the given collection. * * @param collPersister The persister for the collection at which the join should be rooted. * @param collectionName The alias to use for qualifying column references. * @return The generated join sequence. */ public JoinSequence createCollectionJoinSequence(QueryableCollection collPersister, String collectionName) { JoinSequence joinSequence = createJoinSequence(); joinSequence.setRoot( collPersister, collectionName ); joinSequence.setUseThetaStyle( true ); // TODO: figure out how this should be set. /////////////////////////////////////////////////////////////////////////////// // This was the reason for failures regarding INDEX_OP and subclass joins on // theta-join dialects; not sure what behavior we were trying to emulate ;) // joinSequence = joinSequence.getFromPart(); // Emulate the old addFromOnly behavior. return joinSequence; }
public JoinSequence getJoinSequence() { if ( joinSequence != null ) { return joinSequence; } // Class names in the FROM clause result in a JoinSequence (the old FromParser does this). if ( persister instanceof Joinable ) { Joinable joinable = ( Joinable ) persister; return fromElement.getSessionFactoryHelper().createJoinSequence().setRoot( joinable, getTableAlias() ); } else { return null; // TODO: Should this really return null? If not, figure out something better to do here. } }
public JoinSequence getJoinSequence() { if ( joinSequence != null ) { return joinSequence; } // Class names in the FROM clause result in a JoinSequence (the old FromParser does this). if ( persister instanceof Joinable ) { Joinable joinable = ( Joinable ) persister; return fromElement.getSessionFactoryHelper().createJoinSequence().setRoot( joinable, getTableAlias() ); } else { return null; // TODO: Should this really return null? If not, figure out something better to do here. } }
void addFromClass(String name, Queryable classPersister) throws QueryException { JoinSequence joinSequence = new JoinSequence( getFactory() ) .setRoot( classPersister, name ); //crossJoins.add(name); addFrom( name, classPersister.getEntityName(), joinSequence ); }
void addFromClass(String name, Queryable classPersister) throws QueryException { JoinSequence joinSequence = new JoinSequence( getFactory() ) .setRoot( classPersister, name ); //crossJoins.add(name); addFrom( name, classPersister.getEntityName(), joinSequence ); }
private void prepareForIndex(QueryTranslatorImpl q) throws QueryException { QueryableCollection collPersister = q.getCollectionPersister( collectionRole ); if ( !collPersister.hasIndex() ) throw new QueryException( "unindexed collection before []: " + path ); String[] indexCols = collPersister.getIndexColumnNames(); if ( indexCols.length != 1 ) throw new QueryException( "composite-index appears in []: " + path ); //String[] keyCols = collPersister.getKeyColumnNames(); JoinSequence fromJoins = new JoinSequence( q.getFactory() ) .setUseThetaStyle( useThetaStyleJoin ) .setRoot( collPersister, collectionName ) .setNext( joinSequence.copy() ); if ( !continuation ) addJoin( collectionName, collPersister.getCollectionType() ); joinSequence.addCondition( collectionName + '.' + indexCols[0] + " = " ); //TODO: get SQL rendering out of here CollectionElement elem = new CollectionElement(); elem.elementColumns = collPersister.getElementColumnNames(collectionName); elem.elementType = collPersister.getElementType(); elem.isOneToMany = collPersister.isOneToMany(); elem.alias = collectionName; elem.joinSequence = joinSequence; collectionElements.addLast( elem ); setExpectingCollectionIndex(); q.addCollection( collectionName, collectionRole ); q.addFromJoinOnly( collectionName, fromJoins ); }
private void prepareForIndex(QueryTranslatorImpl q) throws QueryException { QueryableCollection collPersister = q.getCollectionPersister( collectionRole ); if ( !collPersister.hasIndex() ) throw new QueryException( "unindexed collection before []: " + path ); String[] indexCols = collPersister.getIndexColumnNames(); if ( indexCols.length != 1 ) throw new QueryException( "composite-index appears in []: " + path ); //String[] keyCols = collPersister.getKeyColumnNames(); JoinSequence fromJoins = new JoinSequence( q.getFactory() ) .setUseThetaStyle( useThetaStyleJoin ) .setRoot( collPersister, collectionName ) .setNext( joinSequence.copy() ); if ( !continuation ) addJoin( collectionName, collPersister.getCollectionType() ); joinSequence.addCondition( collectionName + '.' + indexCols[0] + " = " ); //TODO: get SQL rendering out of here CollectionElement elem = new CollectionElement(); elem.elementColumns = collPersister.getElementColumnNames(collectionName); elem.elementType = collPersister.getElementType(); elem.isOneToMany = collPersister.isOneToMany(); elem.alias = collectionName; elem.joinSequence = joinSequence; collectionElements.addLast( elem ); setExpectingCollectionIndex(); q.addCollection( collectionName, collectionRole ); q.addFromJoinOnly( collectionName, fromJoins ); }
@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; }
elementName : createNameForCollection( collectionRole ); join.setRoot( persister, collectionName ); if ( !persister.isOneToMany() ) {
elementName : createNameForCollection( collectionRole ); join.setRoot( persister, collectionName ); if ( !persister.isOneToMany() ) {