public SessionFactoryImplementor sfi() { return getSessionFactoryHelper().getFactory(); }
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() ); } }
public Dialect getDialect() { return sessionFactoryHelper.getFactory().getServiceRegistry().getService( JdbcServices.class ).getDialect(); }
/** * Determine whether the two types are "assignment compatible". * * @param target The type defined in the into-clause. * @param source The type defined in the select clause. * * @return True if they are assignment compatible. */ private boolean areCompatible(Type target, Type source) { if ( target.equals( source ) ) { // if the types report logical equivalence, return true... return true; } // otherwise, doAfterTransactionCompletion a "deep equivalence" check... if ( !target.getReturnedClass().isAssignableFrom( source.getReturnedClass() ) ) { return false; } int[] targetDatatypes = target.sqlTypes( getSessionFactoryHelper().getFactory() ); int[] sourceDatatypes = source.sqlTypes( getSessionFactoryHelper().getFactory() ); if ( targetDatatypes.length != sourceDatatypes.length ) { return false; } for ( int i = 0; i < targetDatatypes.length; i++ ) { if ( !areSqlTypesCompatible( targetDatatypes[i], sourceDatatypes[i] ) ) { return false; } } return true; }
ArrayHelper.fillArray( "?", type.getColumnSpan( walker.getSessionFactoryHelper().getFactory() )
@Override public void initialize() { // TODO : this really needs to be delayed until after we definitively know the operand node type; // where this is currently a problem is parameters for which where we cannot unequivocally // resolve an expected type Type operandType = extractDataType( getOperand() ); if ( operandType == null ) { return; } SessionFactoryImplementor sessionFactory = getSessionFactoryHelper().getFactory(); int operandColumnSpan = operandType.getColumnSpan( sessionFactory ); if ( operandColumnSpan > 1 ) { mutateRowValueConstructorSyntax( operandColumnSpan ); } }
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 Type getSelectType() { if ( entityType == null ) { return null; } boolean shallow = fromElement.getFromClause().getWalker().isShallowQuery(); return fromElement.getSessionFactoryHelper() .getFactory() .getTypeResolver() .getTypeFactory().manyToOne( entityType.getAssociatedEntityName(), shallow ); }
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 ); } }
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 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; }
protected final void mutateRowValueConstructorSyntaxesIfNecessary(Type lhsType, Type rhsType) { // TODO : this really needs to be delayed until after we definitively know all node types // where this is currently a problem is parameters for which where we cannot unequivocally // resolve an expected type SessionFactoryImplementor sessionFactory = getSessionFactoryHelper().getFactory(); if ( lhsType != null && rhsType != null ) { int lhsColumnSpan = getColumnSpan( lhsType, sessionFactory ); if ( lhsColumnSpan != getColumnSpan( rhsType, sessionFactory ) ) { throw new TypeMismatchException( "left and right hand sides of a binary logic operator were incompatible [" + lhsType.getName() + " : " + rhsType.getName() + "]" ); } if ( lhsColumnSpan > 1 ) { // for dialects which are known to not support ANSI-SQL row-value-constructor syntax, // we should mutate the tree. if ( !sessionFactory.getDialect().supportsRowValueConstructorSyntax() ) { mutateRowValueConstructorSyntax( lhsColumnSpan ); } } } }
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() ); } }
private Constructor resolveConstructor(String path) throws SemanticException { String importedClassName = getSessionFactoryHelper().getImportedClassName( path ); String className = StringHelper.isEmpty( importedClassName ) ? path : importedClassName; if ( className == null ) { throw new SemanticException( "Unable to locate class [" + path + "]" ); } try { final Class holderClass = getSessionFactoryHelper().getFactory() .getServiceRegistry() .getService( ClassLoaderService.class ) .classForName( className ); return ReflectHelper.getConstructor( holderClass, constructorArgumentTypes ); } catch (ClassLoadingException e) { throw new DetailedSemanticException( "Unable to locate class [" + className + "]", e ); } catch (PropertyNotFoundException e) { // this is the exception returned by ReflectHelper.getConstructor() if it cannot // locate an appropriate constructor throw new DetailedSemanticException( formatMissingContructorExceptionMessage( className ), e ); } }
getSessionFactoryHelper().getFactory(), entityType, tableName,
public static MapKeyEntityFromElement buildKeyJoin(FromElement collectionFromElement) { final HqlSqlWalker walker = collectionFromElement.getWalker(); final SessionFactoryHelper sfh = walker.getSessionFactoryHelper(); final SessionFactoryImplementor sf = sfh.getFactory();
final Dialect dialect = getWalker().getSessionFactoryHelper().getFactory().getDialect(); final boolean isInCount = getWalker().isInCount(); final boolean isInDistinctCount = isInCount && getWalker().isInCountDistinct();