diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleInsertQueryPlan.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleInsertQueryPlan.java index f38288efd9..43842518a4 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleInsertQueryPlan.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/internal/SimpleInsertQueryPlan.java @@ -17,7 +17,7 @@ import org.hibernate.query.sqm.sql.SqmInsertTranslator; import org.hibernate.query.sqm.sql.SqmTranslatorFactory; import org.hibernate.query.sqm.tree.expression.SqmParameter; import org.hibernate.query.sqm.tree.insert.SqmInsertStatement; -import org.hibernate.sql.ast.SqlAstInsertSelectTranslator; +import org.hibernate.sql.ast.SqlAstInsertTranslator; import org.hibernate.sql.ast.SqlAstTranslatorFactory; import org.hibernate.sql.ast.spi.FromClauseAccess; import org.hibernate.sql.ast.tree.expression.JdbcParameter; @@ -75,7 +75,7 @@ public class SimpleInsertQueryPlan implements NonSelectQueryPlan { final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); final SqlAstTranslatorFactory sqlAstTranslatorFactory = jdbcEnvironment.getSqlAstTranslatorFactory(); - final SqlAstInsertSelectTranslator sqlAstTranslator = sqlAstTranslatorFactory.buildInsertTranslator( factory ); + final SqlAstInsertTranslator sqlAstTranslator = sqlAstTranslatorFactory.buildInsertTranslator( factory ); jdbcInsert = sqlAstTranslator.translate( sqmInterpretation.getSqlAst() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java index a74d12a8bb..5c7677f9ab 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/idtable/ExecuteWithIdTableHelper.java @@ -23,7 +23,7 @@ import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.query.ComparisonOperator; import org.hibernate.query.NavigablePath; import org.hibernate.query.sqm.mutation.internal.MultiTableSqmMutationConverter; -import org.hibernate.sql.ast.SqlAstInsertSelectTranslator; +import org.hibernate.sql.ast.SqlAstInsertTranslator; import org.hibernate.sql.ast.SqlAstTranslatorFactory; import org.hibernate.sql.ast.spi.SqlExpressionResolver; import org.hibernate.sql.ast.tree.expression.ColumnReference; @@ -129,7 +129,7 @@ public final class ExecuteWithIdTableHelper { final JdbcServices jdbcServices = factory.getJdbcServices(); final JdbcEnvironment jdbcEnvironment = jdbcServices.getJdbcEnvironment(); final SqlAstTranslatorFactory sqlAstTranslatorFactory = jdbcEnvironment.getSqlAstTranslatorFactory(); - final SqlAstInsertSelectTranslator sqlAstTranslator = sqlAstTranslatorFactory.buildInsertTranslator( factory ); + final SqlAstInsertTranslator sqlAstTranslator = sqlAstTranslatorFactory.buildInsertTranslator( factory ); final JdbcInsert jdbcInsert = sqlAstTranslator.translate( idTableInsert ); return jdbcServices.getJdbcMutationExecutor().execute( diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstInsertSelectTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstInsertTranslator.java similarity index 86% rename from hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstInsertSelectTranslator.java rename to hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstInsertTranslator.java index c4405cd725..5501773e9a 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstInsertSelectTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstInsertTranslator.java @@ -12,6 +12,6 @@ import org.hibernate.sql.exec.spi.JdbcInsert; /** * @author Steve Ebersole */ -public interface SqlAstInsertSelectTranslator extends SqlAstTranslator { +public interface SqlAstInsertTranslator extends SqlAstTranslator { JdbcInsert translate(InsertStatement sqlAst); } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstTranslatorFactory.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstTranslatorFactory.java index f63b8006c5..fe5a88f76c 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstTranslatorFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/SqlAstTranslatorFactory.java @@ -27,7 +27,7 @@ public interface SqlAstTranslatorFactory { /** * Builds a single-use insert-select translator */ - SqlAstInsertSelectTranslator buildInsertTranslator(SessionFactoryImplementor sessionFactory); + SqlAstInsertTranslator buildInsertTranslator(SessionFactoryImplementor sessionFactory); SqlAstUpdateTranslator buildUpdateTranslator(SessionFactoryImplementor sessionFactory); diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstDeleteTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstDeleteTranslator.java index 30f4049443..45e92a8a66 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstDeleteTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstDeleteTranslator.java @@ -71,8 +71,7 @@ public class StandardSqlAstDeleteTranslator extends AbstractSqlAstTranslator imp String separator = ""; - for ( int i = 0; i < sqlAst.getCteTable().getCteColumns().size(); i++ ) { - final CteColumn cteColumn = sqlAst.getCteTable().getCteColumns().get( i ); + for ( CteColumn cteColumn : sqlAst.getCteTable().getCteColumns() ) { appendSql( separator ); appendSql( cteColumn.getColumnExpression() ); separator = ", "; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstInsertSelectTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstInsertTranslator.java similarity index 74% rename from hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstInsertSelectTranslator.java rename to hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstInsertTranslator.java index d2e94ed173..f44b2bc71a 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstInsertSelectTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstInsertTranslator.java @@ -10,7 +10,7 @@ import java.util.List; import java.util.Set; import org.hibernate.engine.spi.SessionFactoryImplementor; -import org.hibernate.sql.ast.SqlAstInsertSelectTranslator; +import org.hibernate.sql.ast.SqlAstInsertTranslator; import org.hibernate.sql.ast.tree.cte.CteColumn; import org.hibernate.sql.ast.tree.cte.CteStatement; import org.hibernate.sql.ast.tree.expression.ColumnReference; @@ -23,10 +23,10 @@ import org.hibernate.sql.exec.spi.JdbcParameterBinder; /** * @author Steve Ebersole */ -public class StandardSqlAstInsertSelectTranslator +public class StandardSqlAstInsertTranslator extends AbstractSqlAstTranslator - implements SqlAstInsertSelectTranslator { - public StandardSqlAstInsertSelectTranslator(SessionFactoryImplementor sessionFactory) { + implements SqlAstInsertTranslator { + public StandardSqlAstInsertTranslator(SessionFactoryImplementor sessionFactory) { super( sessionFactory ); } @@ -43,16 +43,15 @@ public class StandardSqlAstInsertSelectTranslator renderImplicitTargetColumnSpec(); } else { - for ( int i = 0; i < targetColumnReferences.size(); i++ ) { - if ( firstPass ) { + for (ColumnReference targetColumnReference : targetColumnReferences) { + if (firstPass) { firstPass = false; } else { appendSql( ", " ); } - final ColumnReference columnReference = targetColumnReferences.get( i ); - appendSql( columnReference.getColumnExpression() ); + appendSql( targetColumnReference.getColumnExpression() ); } } @@ -89,17 +88,17 @@ public class StandardSqlAstInsertSelectTranslator return new JdbcInsert() { @Override public String getSql() { - return StandardSqlAstInsertSelectTranslator.this.getSql(); + return StandardSqlAstInsertTranslator.this.getSql(); } @Override public List getParameterBinders() { - return StandardSqlAstInsertSelectTranslator.this.getParameterBinders(); + return StandardSqlAstInsertTranslator.this.getParameterBinders(); } @Override public Set getAffectedTableNames() { - return StandardSqlAstInsertSelectTranslator.this.getAffectedTableNames(); + return StandardSqlAstInsertTranslator.this.getAffectedTableNames(); } }; } @@ -118,8 +117,7 @@ public class StandardSqlAstInsertSelectTranslator String separator = ""; - for ( int i = 0; i < sqlAst.getCteTable().getCteColumns().size(); i++ ) { - final CteColumn cteColumn = sqlAst.getCteTable().getCteColumns().get( i ); + for ( CteColumn cteColumn : sqlAst.getCteTable().getCteColumns() ) { appendSql( separator ); appendSql( cteColumn.getColumnExpression() ); separator = ", "; @@ -136,17 +134,17 @@ public class StandardSqlAstInsertSelectTranslator return new JdbcInsert() { @Override public String getSql() { - return StandardSqlAstInsertSelectTranslator.this.getSql(); + return StandardSqlAstInsertTranslator.this.getSql(); } @Override public List getParameterBinders() { - return StandardSqlAstInsertSelectTranslator.this.getParameterBinders(); + return StandardSqlAstInsertTranslator.this.getParameterBinders(); } @Override public Set getAffectedTableNames() { - return StandardSqlAstInsertSelectTranslator.this.getAffectedTableNames(); + return StandardSqlAstInsertTranslator.this.getAffectedTableNames(); } }; } diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstSelectTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstSelectTranslator.java index 01d5499b35..c264e4e139 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstSelectTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstSelectTranslator.java @@ -46,8 +46,7 @@ public class StandardSqlAstSelectTranslator String separator = ""; - for ( int i = 0; i < sqlAst.getCteTable().getCteColumns().size(); i++ ) { - final CteColumn cteColumn = sqlAst.getCteTable().getCteColumns().get( i ); + for ( CteColumn cteColumn : sqlAst.getCteTable().getCteColumns() ) { appendSql( separator ); appendSql( cteColumn.getColumnExpression() ); separator = ", "; diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstTranslatorFactory.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstTranslatorFactory.java index ff874b9d9f..d59212b3e2 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstTranslatorFactory.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstTranslatorFactory.java @@ -8,7 +8,7 @@ package org.hibernate.sql.ast.spi; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.sql.ast.SqlAstDeleteTranslator; -import org.hibernate.sql.ast.SqlAstInsertSelectTranslator; +import org.hibernate.sql.ast.SqlAstInsertTranslator; import org.hibernate.sql.ast.SqlAstSelectTranslator; import org.hibernate.sql.ast.SqlAstTranslatorFactory; import org.hibernate.sql.ast.SqlAstUpdateTranslator; @@ -28,8 +28,8 @@ public class StandardSqlAstTranslatorFactory implements SqlAstTranslatorFactory } @Override - public SqlAstInsertSelectTranslator buildInsertTranslator(SessionFactoryImplementor sessionFactory) { - return new StandardSqlAstInsertSelectTranslator( sessionFactory ); + public SqlAstInsertTranslator buildInsertTranslator(SessionFactoryImplementor sessionFactory) { + return new StandardSqlAstInsertTranslator( sessionFactory ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstUpdateTranslator.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstUpdateTranslator.java index 1fc2446c82..6315123c04 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstUpdateTranslator.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/spi/StandardSqlAstUpdateTranslator.java @@ -10,7 +10,6 @@ import java.util.List; import java.util.Set; import org.hibernate.NotYetImplementedFor6Exception; -import org.hibernate.dialect.Dialect; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.sql.ast.SqlAstUpdateTranslator; import org.hibernate.sql.ast.tree.cte.CteStatement; @@ -26,7 +25,7 @@ import org.hibernate.sql.exec.spi.JdbcUpdate; public class StandardSqlAstUpdateTranslator extends AbstractSqlAstTranslator implements SqlAstUpdateTranslator { - private final Dialect dialect; +// private final Dialect dialect; public StandardSqlAstUpdateTranslator(SessionFactoryImplementor sessionFactory) { super( sessionFactory ); @@ -34,7 +33,7 @@ public class StandardSqlAstUpdateTranslator // todo (6.0) : use the Dialect to determine how to handle column references // - specifically should they use the table-alias, the table-expression // or neither for its qualifier - dialect = getSessionFactory().getJdbcServices().getJdbcEnvironment().getDialect(); +// dialect = getSessionFactory().getJdbcServices().getJdbcEnvironment().getDialect(); } private String updatingTableAlias; @@ -48,7 +47,7 @@ public class StandardSqlAstUpdateTranslator appendSql( " set " ); boolean firstPass = true; - for ( int i = 0; i < sqlAst.getAssignments().size(); i++ ) { + for ( Assignment assignment : sqlAst.getAssignments() ) { if ( firstPass ) { firstPass = false; } @@ -56,15 +55,14 @@ public class StandardSqlAstUpdateTranslator appendSql( ", " ); } - final Assignment assignment = sqlAst.getAssignments().get( i ); final List columnReferences = assignment.getAssignable().getColumnReferences(); if ( columnReferences.size() == 1 ) { columnReferences.get( 0 ).accept( this ); } else { appendSql( " (" ); - for ( int cri = 0; cri < columnReferences.size(); cri++ ) { - columnReferences.get( cri ).accept( this ); + for (ColumnReference columnReference : columnReferences) { + columnReference.accept( this ); } appendSql( ") " ); }