public SessionFactoryHelper getSessionFactoryHelper() { return walker.getSessionFactoryHelper(); }
public MultiTableUpdateExecutor(HqlSqlWalker walker) { MultiTableBulkIdStrategy strategy = walker.getSessionFactoryHelper() .getFactory() .getSessionFactoryOptions() .getMultiTableBulkIdStrategy(); this.updateHandler = strategy.buildUpdateHandler( walker.getSessionFactoryHelper().getFactory(), walker ); }
public MultiTableDeleteExecutor(HqlSqlWalker walker) { final MultiTableBulkIdStrategy strategy = walker.getSessionFactoryHelper().getFactory().getSessionFactoryOptions() .getMultiTableBulkIdStrategy(); this.deleteHandler = strategy.buildDeleteHandler( walker.getSessionFactoryHelper().getFactory(), walker ); }
private void initializeSqlNode(AST t) { // Initialize SQL nodes here. if ( t instanceof InitializeableNode ) { InitializeableNode initializeableNode = (InitializeableNode) t; initializeableNode.initialize( walker ); } if ( t instanceof SessionFactoryAwareNode ) { ( (SessionFactoryAwareNode) t ).setSessionFactory( walker.getSessionFactoryHelper().getFactory() ); } }
@Override public Type getDataType() { Type type = super.getDataType(); if ( type != null ) { return type; } FromElement fe = getFromElement(); if ( fe != null ) { return fe.getDataType(); } SQLFunction sf = getWalker().getSessionFactoryHelper().findSQLFunction( getText() ); if ( sf != null ) { return sf.getReturnType( null, getWalker().getSessionFactoryHelper().getFactory() ); } return null; }
ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() )
public void lookupConstant(DotNode node) throws SemanticException { String text = ASTUtil.getPathText( node ); Queryable persister = walker.getSessionFactoryHelper().findQueryableUsingImports( text ); if ( persister != null ) { // the name of an entity class final String discrim = persister.getDiscriminatorSQLValue(); node.setDataType( persister.getDiscriminatorType() ); if ( InFragment.NULL.equals( discrim ) || InFragment.NOT_NULL.equals( discrim ) ) { throw new InvalidPathException( "subclass test not allowed for null or not null discriminator: '" + text + "'" ); } // the class discriminator value setSQLValue( node, text, discrim ); } else { Object value = ReflectHelper.getConstantValue( text, walker.getSessionFactoryHelper().getFactory() ); if ( value == null ) { throw new InvalidPathException( "Invalid path: '" + text + "'" ); } setConstantValue( node, text, value ); } }
private void initText() { String[] cols = getColumns(); String text = String.join( ", ", cols ); boolean countDistinct = getWalker().isInCountDistinct() && getWalker().getSessionFactoryHelper().getFactory().getDialect().requiresParensForTupleDistinctCounts(); if ( cols.length > 1 && ( getWalker().isComparativeExpressionClause() || countDistinct ) ) { text = "(" + text + ")"; } setText( text ); }
public void initialize(Queryable persister) { if ( persister.isAbstract() ) { throw new QueryException( "cannot insert into abstract class (no table)" ); } this.persister = persister; initializeColumns(); if ( getWalker().getSessionFactoryHelper().hasPhysicalDiscriminatorColumn( persister ) ) { discriminated = true; columnSpec += ", " + persister.getDiscriminatorColumnName(); } resetText(); }
@Override protected AST createIntoClause(String path, AST propertySpec) throws SemanticException { Queryable persister = (Queryable) getSessionFactoryHelper().requireClassPersister( path ); IntoClause intoClause = (IntoClause) getASTFactory().create( INTO, persister.getEntityName() ); intoClause.setFirstChild( propertySpec ); intoClause.initialize( persister ); addQuerySpaces( persister.getQuerySpaces() ); return intoClause; }
public BasicExecutor(HqlSqlWalker walker, Queryable persister) { this.persister = persister; try { SqlGenerator gen = new SqlGenerator( walker.getSessionFactoryHelper().getFactory() ); gen.statement( walker.getAST() ); sql = gen.getSQL(); gen.getParseErrorHandler().throwQueryException(); parameterSpecifications = gen.getCollectedParameters(); } catch ( RecognitionException e ) { throw QuerySyntaxException.convert( e ); } }
@Override protected AST generatePositionalParameter(AST delimiterNode, AST numberNode) throws SemanticException { if ( getSessionFactoryHelper().isStrictJPAQLComplianceEnabled() && namedParameters != null ) { throw new SemanticException( "Cannot mix positional and named parameters: " + queryTranslatorImpl.getQueryString()
@Override protected AST generateNamedParameter(AST delimiterNode, AST nameNode) throws SemanticException { if ( getSessionFactoryHelper().isStrictJPAQLComplianceEnabled() && positionalParameters != null ) { throw new SemanticException( "Cannot mix positional and named parameters: " + queryTranslatorImpl.getQueryString() ); } final String name = nameNode.getText(); trackNamedParameterPositions( name ); // create the node initially with the param name so that it shows // appropriately in the "original text" attribute final ParameterNode parameter = (ParameterNode) astFactory.create( NAMED_PARAM, name ); parameter.setText( "?" ); final NamedParameterSpecification paramSpec = new NamedParameterSpecification( delimiterNode.getLine(), delimiterNode.getColumn(), name ); parameter.setHqlParameterSpecification( paramSpec ); parameterSpecs.add( paramSpec ); return parameter; }
type = walker.getSessionFactoryHelper().getFactory().getTypeResolver().heuristicType( value.getClass().getName() ); Dialect dialect = walker.getSessionFactoryHelper().getFactory().getDialect();
public void processConstant(AST constant, boolean resolveIdent) throws SemanticException { // If the constant is an IDENT, figure out what it means... boolean isIdent = ( constant.getType() == IDENT || constant.getType() == WEIRD_IDENT ); if ( resolveIdent && isIdent && isAlias( constant.getText() ) ) { // IDENT is a class alias in the FROM. IdentNode ident = (IdentNode) constant; // Resolve to an identity column. ident.resolve( false, true ); } else { // IDENT might be the name of a class. Queryable queryable = walker.getSessionFactoryHelper().findQueryableUsingImports( constant.getText() ); if ( isIdent && queryable != null ) { constant.setText( queryable.getDiscriminatorSQLValue() ); } // Otherwise, it's a literal. else { processLiteral( constant ); } } }
public DeleteExecutor(HqlSqlWalker walker, Queryable persister) { super( walker, persister ); final SessionFactoryImplementor factory = walker.getSessionFactoryHelper().getFactory(); final Dialect dialect = factory.getJdbcServices().getJdbcEnvironment().getDialect();
private void handleWithFragment(FromElement fromElement, AST hqlWithNode) throws SemanticException { try { withClause( hqlWithNode ); AST hqlSqlWithNode = returnAST; if ( LOG.isDebugEnabled() ) { LOG.debug( "handleWithFragment() : " + getASTPrinter().showAsString( hqlSqlWithNode, "-- with clause --" ) ); } WithClauseVisitor visitor = new WithClauseVisitor( fromElement, queryTranslatorImpl ); NodeTraverser traverser = new NodeTraverser( visitor ); traverser.traverseDepthFirst( hqlSqlWithNode ); SqlGenerator sql = new SqlGenerator( getSessionFactoryHelper().getFactory() ); sql.whereExpr( hqlSqlWithNode.getFirstChild() ); fromElement.setWithClauseFragment( "(" + sql.getSQL() + ")" ); } catch (SemanticException e) { throw e; } catch (InvalidWithClauseException e) { throw e; } catch (Exception e) { throw new SemanticException( e.getMessage() ); } }
Type collectionFilterKeyType = hqlSqlWalker.getSessionFactoryHelper() .requireQueryableCollection( hqlSqlWalker.getCollectionFilterRole() ) .getKeyType();
final Dialect dialect = getWalker().getSessionFactoryHelper().getFactory().getDialect(); final boolean isInCount = getWalker().isInCount(); final boolean isInDistinctCount = isInCount && getWalker().isInCountDistinct();
public static MapKeyEntityFromElement buildKeyJoin(FromElement collectionFromElement) { final HqlSqlWalker walker = collectionFromElement.getWalker(); final SessionFactoryHelper sfh = walker.getSessionFactoryHelper(); final SessionFactoryImplementor sf = sfh.getFactory();