private boolean isCorrelation() { FromClause top = fromElement.getWalker().getFinalFromClause(); return fromElement.getFromClause() != fromElement.getWalker().getCurrentFromClause() && fromElement.getFromClause() == top; }
public void setOrigin(FromElement origin, boolean manyToMany) { this.origin = origin; this.manyToMany = manyToMany; origin.addDestination( this ); if ( origin.getFromClause() == this.getFromClause() ) { // TODO: Figure out a better way to get the FROM elements in a proper tree structure. // If this is not the destination of a many-to-many, add it as a child of the origin. if ( manyToMany ) { ASTUtil.appendSibling( origin, this ); } else { if ( !getWalker().isInFrom() && !getWalker().isInSelect() && !getWalker().isInEntityGraph() ) { getFromClause().addChild( this ); } else { origin.addChild( this ); } } } else if ( !getWalker().isInFrom() ) { // HHH-276 : implied joins in a subselect where clause - The destination needs to be added // to the destination's from clause. getFromClause().addChild( this ); // Not sure if this is will fix everything, but it works. } else { // Otherwise, the destination node was implied by the FROM clause and the FROM clause processor // will automatically add it in the right place. } }
@SuppressWarnings("SimplifiableIfStatement") protected boolean isFromElementUpdateOrDeleteRoot(FromElement element) { if ( element.getFromClause().getParentFromClause() != null ) { // its not even a root... return false; } return getWalker().getStatementType() == HqlSqlTokenTypes.DELETE || getWalker().getStatementType() == HqlSqlTokenTypes.UPDATE; }
checkInitialized(); if ( fromElement.getFromClause().isSubQuery() ) {
private boolean isCorrelatedSubselect() { return getWalker().isSubQuery() && getFromElement().getFromClause() != getWalker().getCurrentFromClause(); }
private boolean canReuse(String classAlias, FromElement fromElement) { // if the from-clauses are the same, we can be a little more aggressive in terms of what we reuse if ( fromElement.getFromClause() == getWalker().getCurrentFromClause() && areSame( classAlias, fromElement.getClassAlias() )) { return true; } // otherwise (subquery case) dont reuse the fromElement if we are processing the from-clause of the subquery return getWalker().getCurrentClauseType() != SqlTokenTypes.FROM; }
SelectExpression expr, ASTAppender appender) { if ( !fromElement.getFromClause().isSubQuery() ) { if ( !scalarSelect && !getWalker().isShallowQuery() ) {
@Override public void prepareForDot(String propertyName) throws SemanticException { FromElement fromElement = getFromElement(); if ( fromElement == null ) { throw new IllegalStateException( "No FROM element for index operator!" ); } final QueryableCollection queryableCollection = fromElement.getQueryableCollection(); if ( queryableCollection != null && !queryableCollection.isOneToMany() ) { final FromReferenceNode collectionNode = (FromReferenceNode) getFirstChild(); final String path = collectionNode.getPath() + "[]." + propertyName; LOG.debugf( "Creating join for many-to-many elements for %s", path ); final FromElementFactory factory = new FromElementFactory( fromElement.getFromClause(), fromElement, path ); // This will add the new from element to the origin. final FromElement elementJoin = factory.createElementJoin( queryableCollection ); setFromElement( elementJoin ); } }
public Type getSelectType() { if ( entityType == null ) { return null; } boolean shallow = fromElement.getFromClause().getWalker().isShallowQuery(); return fromElement.getSessionFactoryHelper() .getFactory() .getTypeResolver() .getTypeFactory().manyToOne( entityType.getAssociatedEntityName(), shallow ); }
if ( fromElement.getFromClause() != fromClause ) { LOG.debug( "createFromElementInSubselect() : creating a new FROM element..." ); fromElement = createFromElement( entityPersister );
if ( elem.getFromClause() != elem.getOrigin().getFromClause() ||
( fromElement.getFromClause().isSubQuery()
String pathRoot = StringHelper.root( path ); FromElement origin = fromClause.getFromElement( pathRoot ); if ( origin == null || origin.getFromClause() != fromClause ) { implied = true;
@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; }
collectionFromElement.getFromClause(), indexEntityPersister.getEntityName(), indexEntityPersister,
FromClause fromClause = fromElement.getFromClause(); String path = collectionNode.getPath();
private boolean isCorrelation() { FromClause top = fromElement.getWalker().getFinalFromClause(); return fromElement.getFromClause() != fromElement.getWalker().getCurrentFromClause() && fromElement.getFromClause() == top; }
private boolean isCorrelatedSubselect() { return getWalker().isSubQuery() && getFromElement().getFromClause() != getWalker().getCurrentFromClause(); }
private void renderNonScalarIdentifiers(FromElement fromElement, int nonscalarSize, int j, SelectExpression expr, ASTAppender appender) { String text = fromElement.renderIdentifierSelect( nonscalarSize, j ); if ( !fromElement.getFromClause().isSubQuery() ) { if ( !scalarSelect && !getWalker().isShallowQuery() ) { //TODO: is this a bit ugly? expr.setText( text ); } else { appender.append( SqlTokenTypes.SQL_TOKEN, text, false ); } } }
public Type getSelectType() { if (entityType==null) return null; boolean shallow = fromElement.getFromClause().getWalker().isShallowQuery(); return fromElement.getSessionFactoryHelper() .getFactory() .getTypeResolver() .getTypeFactory().manyToOne( entityType.getAssociatedEntityName(), shallow ); }