private boolean inWhereClause() { return fromElement.getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.WHERE; }
private boolean isUpdateQuery() { return fromElement.getWalker().getStatementType() == HqlSqlTokenTypes.UPDATE; }
private boolean isInsertQuery() { return fromElement.getWalker().getStatementType() == HqlSqlTokenTypes.INSERT; }
public void setFetch(boolean fetch) { this.fetch = fetch; // Fetch can't be used with scroll() or iterate(). if ( fetch && getWalker().isShallowQuery() ) { throw new QueryException( QueryTranslator.ERROR_CANNOT_FETCH_WITH_ITERATE ); } }
public void setRole(String role) { this.role = role; applyTreatAsDeclarations( getWalker().getTreatAsDeclarationsByPath( role ) ); }
public String[] getIdentityColumns() { checkInitialized(); final String table = getTableAlias(); if ( table == null ) { throw new IllegalStateException( "No table alias for node " + this ); } final String[] propertyNames = getIdentifierPropertyNames(); List<String> columns = new ArrayList<>(); for ( int i = 0; i < propertyNames.length; i++ ) { String[] propertyNameColumns = toColumns( table, propertyNames[i], getWalker().getStatementType() == HqlSqlTokenTypes.SELECT ); for ( int j = 0; j < propertyNameColumns.length; j++ ) { columns.add( propertyNameColumns[j] ); } } return columns.toArray( new String[columns.size()] ); }
protected void initializeComponentJoin(FromElementType elementType) { fromClause.registerFromElement( this ); elementType.applyTreatAsDeclarations( getWalker().getTreatAsDeclarationsByPath( classAlias ) ); this.elementType = elementType; initialized = true; }
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. } }
@Override public String[] toColumns(final String tableAlias) { if ( propertyName.equalsIgnoreCase( "index" ) ) { return collectionPropertyMapping.toColumns( tableAlias, propertyName ); } Map enabledFilters = fromElement.getWalker().getEnabledFilters(); String subquery = CollectionSubqueryFactory.createCollectionSubquery( joinSequence.copyForCollectionProperty().setUseThetaStyle( true ), enabledFilters, collectionPropertyMapping.toColumns( tableAlias, propertyName ) ); LOG.debugf( "toColumns(%s,%s) : subquery = %s", tableAlias, propertyName, subquery ); return new String[] {"(" + subquery + ")"}; } };
if ( fromElement.getWalker().getStatementType() == HqlSqlTokenTypes.SELECT ) { return propertyMapping.toColumns( tableAlias, path ); if ( fromElement.getWalker().isSubQuery() ) { if ( fromElement.getWalker().getCurrentTopLevelClauseType() == HqlSqlTokenTypes.SELECT ) { return propertyMapping.toColumns( tableAlias, path );
public static MapKeyEntityFromElement buildKeyJoin(FromElement collectionFromElement) { final HqlSqlWalker walker = collectionFromElement.getWalker(); final SessionFactoryHelper sfh = walker.getSessionFactoryHelper(); final SessionFactoryImplementor sf = sfh.getFactory(); join.initialize( collectionFromElement.getWalker() );
elem.setImpliedInFromClause( true ); if ( elem.getWalker().isSubQuery() ) {
public void setFetch(boolean fetch) { this.fetch = fetch; // Fetch can't be used with scroll() or iterate(). if ( fetch && getWalker().isShallowQuery() ) { throw new QueryException( QueryTranslator.ERROR_CANNOT_FETCH_WITH_ITERATE ); } }
public void setFetch(boolean fetch) { this.fetch = fetch; // Fetch can't be used with scroll() or iterate(). if ( fetch && getWalker().isShallowQuery() ) { throw new QueryException( QueryTranslator.ERROR_CANNOT_FETCH_WITH_ITERATE ); } }
public String getIdentityColumn() { checkInitialized(); String table = getTableAlias(); if ( table == null ) { throw new IllegalStateException( "No table alias for node " + this ); } String[] cols; String propertyName; if ( getEntityPersister() != null && getEntityPersister().getEntityMetamodel() != null && getEntityPersister().getEntityMetamodel().hasNonIdentifierPropertyNamedId() ) { propertyName = getEntityPersister().getIdentifierPropertyName(); } else { propertyName = EntityPersister.ENTITY_ID; } if ( getWalker().getStatementType() == HqlSqlTokenTypes.SELECT ) { cols = getPropertyMapping( propertyName ).toColumns( table, propertyName ); } else { cols = getPropertyMapping( propertyName ).toColumns( propertyName ); } String result = StringHelper.join( ", ", cols ); return cols.length == 1 ? result : "(" + result + ")"; }
public String getIdentityColumn() { checkInitialized(); String table = getTableAlias(); if ( table == null ) { throw new IllegalStateException( "No table alias for node " + this ); } String[] cols; String propertyName; if ( getEntityPersister() != null && getEntityPersister().getEntityMetamodel() != null && getEntityPersister().getEntityMetamodel().hasNonIdentifierPropertyNamedId() ) { propertyName = getEntityPersister().getIdentifierPropertyName(); } else { propertyName = EntityPersister.ENTITY_ID; } if ( getWalker().getStatementType() == HqlSqlTokenTypes.SELECT ) { cols = getPropertyMapping( propertyName ).toColumns( table, propertyName ); } else { cols = getPropertyMapping( propertyName ).toColumns( propertyName ); } String result = StringHelper.join( ", ", cols ); return cols.length == 1 ? result : "(" + result + ")"; }