From 169646875b3eef1f98427c46645bc0070afdc476 Mon Sep 17 00:00:00 2001 From: Steve Ebersole Date: Mon, 11 Nov 2019 17:25:27 -0600 Subject: [PATCH] HHH-13715 - working support for "multi-table" HQL/Criteria UPDATE and DELETE queries; work on CTE-base multi-table handling --- .../dialect/AbstractTransactSQLDialect.java | 5 ++++- .../java/org/hibernate/dialect/Cache71Dialect.java | 5 ++++- .../java/org/hibernate/dialect/DB297Dialect.java | 5 ++++- .../main/java/org/hibernate/dialect/DB2Dialect.java | 5 ++++- .../java/org/hibernate/dialect/DerbyDialect.java | 5 ++++- .../src/main/java/org/hibernate/dialect/Dialect.java | 5 ++++- .../main/java/org/hibernate/dialect/H2Dialect.java | 6 ++++-- .../hibernate/dialect/HANAColumnStoreDialect.java | 5 ++++- .../org/hibernate/dialect/HANARowStoreDialect.java | 5 ++++- .../main/java/org/hibernate/dialect/HSQLDialect.java | 6 ++++-- .../java/org/hibernate/dialect/InformixDialect.java | 6 ++++-- .../java/org/hibernate/dialect/IngresDialect.java | 6 ++++-- .../java/org/hibernate/dialect/MariaDBDialect.java | 12 ++++++++++++ .../java/org/hibernate/dialect/MySQLDialect.java | 6 ++++-- .../java/org/hibernate/dialect/Oracle8iDialect.java | 6 ++++-- .../java/org/hibernate/dialect/Oracle9Dialect.java | 6 ++++-- .../org/hibernate/dialect/PostgreSQL81Dialect.java | 5 ++++- .../org/hibernate/dialect/PostgreSQL82Dialect.java | 5 ++++- .../java/org/hibernate/dialect/SAPDBDialect.java | 5 ++++- .../java/org/hibernate/dialect/TeradataDialect.java | 5 ++++- .../java/org/hibernate/dialect/TimesTenDialect.java | 6 ++++-- .../mutation/internal/SqmMutationStrategyHelper.java | 3 +-- .../internal/cte/CteBasedMutationStrategy.java | 8 ++++---- .../org/hibernate/sql/ast/tree/cte/CteTable.java | 6 +++--- .../hibernate/orm/test/loading/MappedFetchTests.java | 6 +++--- 25 files changed, 103 insertions(+), 40 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java index 94808ed5e0..7ee6b1c894 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/AbstractTransactSQLDialect.java @@ -25,6 +25,7 @@ import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.dialect.identity.AbstractTransactSQLIdentityColumnSupport; import org.hibernate.dialect.identity.IdentityColumnSupport; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.internal.idtable.AfterUseAction; import org.hibernate.query.sqm.mutation.internal.idtable.IdTable; import org.hibernate.query.sqm.mutation.internal.idtable.LocalTemporaryTableStrategy; @@ -214,7 +215,9 @@ abstract class AbstractTransactSQLDialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType entityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType entityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { return new LocalTemporaryTableStrategy( new IdTable( entityDescriptor, basename -> "#" + basename ), // // sql-server, at least needed this dropped after use; strange! diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Cache71Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Cache71Dialect.java index 41830f595a..feb32dad1b 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Cache71Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Cache71Dialect.java @@ -39,6 +39,7 @@ import org.hibernate.exception.spi.SQLExceptionConversionDelegate; import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.spi.ViolatedConstraintNameExtracter; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.persister.entity.Lockable; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.sql.CacheJoinFragment; @@ -444,7 +445,9 @@ public class Cache71Dialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new GlobalTemporaryTableBulkIdStrategy( // new IdTableSupportStandardImpl() { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DB297Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DB297Dialect.java index 69e8ebc7b4..31d2b8ffda 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DB297Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DB297Dialect.java @@ -11,6 +11,7 @@ import java.sql.Types; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.dialect.function.DB2SubstringFunction; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.type.descriptor.sql.CharTypeDescriptor; import org.hibernate.type.descriptor.sql.ClobTypeDescriptor; @@ -36,7 +37,9 @@ public class DB297Dialect extends DB2Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // // Starting in DB2 9.7, "real" global temporary tables that can be shared between sessions diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java index a8465e953d..24b169f50b 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DB2Dialect.java @@ -34,6 +34,7 @@ import org.hibernate.exception.LockTimeoutException; import org.hibernate.exception.spi.SQLExceptionConversionDelegate; import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorDB2DatabaseImpl; import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorNoOpImpl; @@ -393,7 +394,9 @@ public class DB2Dialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // // Prior to DB2 9.7, "real" global temporary tables that can be shared between sessions diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java index 0024ee0182..c3ba21a10e 100755 --- a/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/DerbyDialect.java @@ -25,6 +25,7 @@ import org.hibernate.engine.spi.RowSelection; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.internal.idtable.AfterUseAction; import org.hibernate.query.sqm.mutation.internal.idtable.IdTable; import org.hibernate.query.sqm.mutation.internal.idtable.LocalTemporaryTableStrategy; @@ -599,7 +600,9 @@ public class DerbyDialect extends DB2Dialect { * see HHH-10238. */ @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { return new LocalTemporaryTableStrategy( new IdTable( rootEntityDescriptor, basename -> "HT_" + basename ), () -> new TempIdTableExporter() { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java index 6aac973dc1..ed332f2b02 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Dialect.java @@ -93,6 +93,7 @@ import org.hibernate.mapping.ForeignKey; import org.hibernate.mapping.Index; import org.hibernate.mapping.Table; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.persister.entity.Lockable; import org.hibernate.procedure.internal.StandardCallableStatementSupport; import org.hibernate.procedure.spi.CallableStatementSupport; @@ -1515,7 +1516,9 @@ public abstract class Dialect implements ConversionContext { return getCreateTableString(); } - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType entityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType entityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java index 8051252090..cbb68bdd88 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/H2Dialect.java @@ -33,7 +33,7 @@ import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.metamodel.mapping.EntityMappingType; -import org.hibernate.persister.entity.Queryable; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.internal.idtable.AfterUseAction; import org.hibernate.query.sqm.mutation.internal.idtable.IdTable; import org.hibernate.query.sqm.mutation.internal.idtable.LocalTemporaryTableStrategy; @@ -372,7 +372,9 @@ public class H2Dialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType entityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType entityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { return new LocalTemporaryTableStrategy( new IdTable( entityDescriptor, basename -> "HT_" + basename ), AfterUseAction.NONE, diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/HANAColumnStoreDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/HANAColumnStoreDialect.java index 73eb048f3d..275a658891 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/HANAColumnStoreDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/HANAColumnStoreDialect.java @@ -11,6 +11,7 @@ import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.type.StandardBasicTypes; @@ -48,7 +49,9 @@ public class HANAColumnStoreDialect extends AbstractHANADialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new GlobalTemporaryTableBulkIdStrategy( new IdTableSupportStandardImpl() { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/HANARowStoreDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/HANARowStoreDialect.java index e7540cdf3a..d7a908ca50 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/HANARowStoreDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/HANARowStoreDialect.java @@ -8,6 +8,7 @@ package org.hibernate.dialect; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; /** @@ -36,7 +37,9 @@ public class HANARowStoreDialect extends AbstractHANADialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new GlobalTemporaryTableBulkIdStrategy( new IdTableSupportStandardImpl() { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java index 87d8ec9053..da319e0f4e 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/HSQLDialect.java @@ -43,7 +43,7 @@ import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.metamodel.mapping.EntityMappingType; -import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.persister.entity.Lockable; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorHSQLDBDatabaseImpl; @@ -504,7 +504,9 @@ public class HSQLDialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // // Hibernate uses this information for temporary tables that it uses for its own operations diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java index e91008712e..d114b9a037 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/InformixDialect.java @@ -10,7 +10,6 @@ import java.sql.SQLException; import java.sql.Types; import java.util.Locale; -import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.boot.TempTableDdlTransactionHandling; import org.hibernate.dialect.function.NoArgSQLFunction; import org.hibernate.dialect.function.NvlFunction; @@ -27,6 +26,7 @@ import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.spi.ViolatedConstraintNameExtracter; import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.internal.idtable.AfterUseAction; import org.hibernate.query.sqm.mutation.internal.idtable.IdTable; import org.hibernate.query.sqm.mutation.internal.idtable.LocalTemporaryTableStrategy; @@ -284,7 +284,9 @@ public class InformixDialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { return new LocalTemporaryTableStrategy( new IdTable( rootEntityDescriptor, basename -> "HT_" + basename ), () -> new TempIdTableExporter() { diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/IngresDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/IngresDialect.java index 06a2a03bcc..d90f59fefe 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/IngresDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/IngresDialect.java @@ -18,7 +18,7 @@ import org.hibernate.dialect.pagination.FirstLimitHandler; import org.hibernate.dialect.pagination.LegacyFirstLimitHandler; import org.hibernate.dialect.pagination.LimitHandler; import org.hibernate.metamodel.mapping.EntityMappingType; -import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.tool.schema.extract.internal.SequenceNameExtractorImpl; import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor; @@ -271,7 +271,9 @@ public class IngresDialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new GlobalTemporaryTableBulkIdStrategy( diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/MariaDBDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/MariaDBDialect.java index db6b858134..d419798275 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/MariaDBDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/MariaDBDialect.java @@ -6,6 +6,11 @@ */ package org.hibernate.dialect; +import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; +import org.hibernate.query.sqm.mutation.internal.cte.CteBasedMutationStrategy; +import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; + /** * @author Vlad Mihalcea */ @@ -18,6 +23,13 @@ public class MariaDBDialect extends MySQL5Dialect { return true; } + @Override + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { + return new CteBasedMutationStrategy( rootEntityDescriptor.getEntityPersister(), runtimeModelCreationContext ); + } + @Override protected MySQLStorageEngine getDefaultMySQLStorageEngine() { return InnoDBStorageEngine.INSTANCE; diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java index f8f8221711..ef40148502 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/MySQLDialect.java @@ -14,7 +14,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import org.hibernate.JDBCException; -import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.NullPrecedence; import org.hibernate.PessimisticLockException; import org.hibernate.boot.TempTableDdlTransactionHandling; @@ -35,6 +34,7 @@ import org.hibernate.exception.spi.SQLExceptionConversionDelegate; import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.mapping.Column; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.internal.idtable.AfterUseAction; import org.hibernate.query.sqm.mutation.internal.idtable.IdTable; import org.hibernate.query.sqm.mutation.internal.idtable.LocalTemporaryTableStrategy; @@ -348,7 +348,9 @@ public class MySQLDialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { return new LocalTemporaryTableStrategy( new IdTable( rootEntityDescriptor, basename -> "HT_" + basename ), diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java index b50a0f2853..c7503e2fe4 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle8iDialect.java @@ -36,7 +36,7 @@ import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.spi.ViolatedConstraintNameExtracter; import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.metamodel.mapping.EntityMappingType; -import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.procedure.internal.StandardCallableStatementSupport; import org.hibernate.procedure.spi.CallableStatementSupport; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; @@ -623,7 +623,9 @@ public class Oracle8iDialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new GlobalTemporaryTableBulkIdStrategy( diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java index f25fac12cb..df45817840 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/Oracle9Dialect.java @@ -18,7 +18,7 @@ import org.hibernate.exception.spi.ViolatedConstraintNameExtracter; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.metamodel.mapping.EntityMappingType; -import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.tool.schema.extract.internal.SequenceInformationExtractorOracleDatabaseImpl; import org.hibernate.tool.schema.extract.spi.SequenceInformationExtractor; @@ -345,7 +345,9 @@ public class Oracle9Dialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new GlobalTemporaryTableBulkIdStrategy( diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java index a2e9af88c7..c993ec7b6e 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL81Dialect.java @@ -37,6 +37,7 @@ import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtracter; import org.hibernate.exception.spi.ViolatedConstraintNameExtracter; import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.procedure.internal.PostgresCallableStatementSupport; import org.hibernate.procedure.spi.CallableStatementSupport; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; @@ -366,7 +367,9 @@ public class PostgreSQL81Dialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new LocalTemporaryTableBulkIdStrategy( diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL82Dialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL82Dialect.java index fcf8ccd7bb..5d62b4eccd 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL82Dialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/PostgreSQL82Dialect.java @@ -9,6 +9,7 @@ package org.hibernate.dialect; import org.hibernate.NotYetImplementedFor6Exception; import org.hibernate.boot.model.TypeContributions; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.service.ServiceRegistry; import org.hibernate.type.PostgresUUIDType; @@ -33,7 +34,9 @@ public class PostgreSQL82Dialect extends PostgreSQL81Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new LocalTemporaryTableBulkIdStrategy( diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/SAPDBDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/SAPDBDialect.java index 46816a0b3e..8e39fb92c5 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/SAPDBDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/SAPDBDialect.java @@ -16,6 +16,7 @@ import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.StandardSQLFunction; import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.sql.CaseFragment; import org.hibernate.sql.DecodeCaseFragment; @@ -226,7 +227,9 @@ public class SAPDBDialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new LocalTemporaryTableBulkIdStrategy( diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java index c50a90df27..fa3e7efbb6 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/TeradataDialect.java @@ -14,6 +14,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.dialect.function.SQLFunctionTemplate; import org.hibernate.dialect.function.VarArgsSQLFunction; import org.hibernate.metamodel.mapping.EntityMappingType; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.type.StandardBasicTypes; @@ -120,7 +121,9 @@ public class TeradataDialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new GlobalTemporaryTableBulkIdStrategy( this, AfterUseAction.CLEAN ); } diff --git a/hibernate-core/src/main/java/org/hibernate/dialect/TimesTenDialect.java b/hibernate-core/src/main/java/org/hibernate/dialect/TimesTenDialect.java index 13087d93bb..d2c160aaa7 100644 --- a/hibernate-core/src/main/java/org/hibernate/dialect/TimesTenDialect.java +++ b/hibernate-core/src/main/java/org/hibernate/dialect/TimesTenDialect.java @@ -25,7 +25,7 @@ import org.hibernate.dialect.pagination.FirstLimitHandler; import org.hibernate.dialect.pagination.LegacyFirstLimitHandler; import org.hibernate.dialect.pagination.LimitHandler; import org.hibernate.metamodel.mapping.EntityMappingType; -import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.persister.entity.Lockable; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; import org.hibernate.sql.JoinFragment; @@ -219,7 +219,9 @@ public class TimesTenDialect extends Dialect { } @Override - public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(EntityMappingType rootEntityDescriptor) { + public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy( + EntityMappingType rootEntityDescriptor, + RuntimeModelCreationContext runtimeModelCreationContext) { throw new NotYetImplementedFor6Exception( getClass() ); // return new GlobalTemporaryTableBulkIdStrategy( diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/SqmMutationStrategyHelper.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/SqmMutationStrategyHelper.java index 93fe9bf55c..e24cbd1340 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/SqmMutationStrategyHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/SqmMutationStrategyHelper.java @@ -19,7 +19,6 @@ import org.hibernate.query.spi.QueryEngine; import org.hibernate.query.spi.QueryParameterImplementor; import org.hibernate.query.sqm.internal.DomainParameterXref; import org.hibernate.query.sqm.internal.SqmUtil; -import org.hibernate.query.sqm.mutation.internal.idtable.IdTable; import org.hibernate.query.sqm.mutation.spi.DeleteHandler; import org.hibernate.query.sqm.mutation.spi.HandlerCreationContext; import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy; @@ -78,7 +77,7 @@ public class SqmMutationStrategyHelper { return serviceRegistry.getService( JdbcServices.class ) .getJdbcEnvironment() .getDialect() - .getFallbackSqmMutationStrategy( runtimeRootEntityDescriptor ); + .getFallbackSqmMutationStrategy( runtimeRootEntityDescriptor, ); } /** diff --git a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteBasedMutationStrategy.java b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteBasedMutationStrategy.java index 330264fc7b..17a38d26c7 100644 --- a/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteBasedMutationStrategy.java +++ b/hibernate-core/src/main/java/org/hibernate/query/sqm/mutation/internal/cte/CteBasedMutationStrategy.java @@ -8,9 +8,9 @@ package org.hibernate.query.sqm.mutation.internal.cte; import java.util.Locale; -import org.hibernate.boot.spi.BootstrapContext; import org.hibernate.dialect.Dialect; import org.hibernate.engine.jdbc.spi.JdbcServices; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.query.sqm.internal.DomainParameterXref; import org.hibernate.query.sqm.mutation.spi.DeleteHandler; @@ -89,10 +89,10 @@ public class CteBasedMutationStrategy implements SqmMultiTableMutationStrategy { public CteBasedMutationStrategy( EntityPersister rootDescriptor, - BootstrapContext bootstrapContext) { + RuntimeModelCreationContext runtimeModelCreationContext) { this.rootDescriptor = rootDescriptor; - final Dialect dialect = bootstrapContext.getTypeConfiguration() + final Dialect dialect = runtimeModelCreationContext.getTypeConfiguration() .getSessionFactory() .getServiceRegistry() .getService( JdbcServices.class ) @@ -120,7 +120,7 @@ public class CteBasedMutationStrategy implements SqmMultiTableMutationStrategy { ); } - this.cteTable = new CteTable( rootDescriptor, bootstrapContext ); + this.cteTable = new CteTable( rootDescriptor, runtimeModelCreationContext ); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java index 1d5bb77c0f..736d10f42f 100644 --- a/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java +++ b/hibernate-core/src/main/java/org/hibernate/sql/ast/tree/cte/CteTable.java @@ -11,11 +11,11 @@ import java.util.Collections; import java.util.List; import org.hibernate.LockMode; -import org.hibernate.boot.spi.BootstrapContext; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.internal.util.StringHelper; import org.hibernate.metamodel.mapping.EntityMappingType; import org.hibernate.metamodel.mapping.JdbcMapping; +import org.hibernate.metamodel.spi.RuntimeModelCreationContext; import org.hibernate.query.NavigablePath; import org.hibernate.query.sqm.mutation.internal.cte.CteBasedMutationStrategy; import org.hibernate.sql.ast.Clause; @@ -41,11 +41,11 @@ public class CteTable { private final List cteColumns; - public CteTable(EntityMappingType entityDescriptor, BootstrapContext bootstrapContext) { + public CteTable(EntityMappingType entityDescriptor, RuntimeModelCreationContext runtimeModelCreationContext) { this.entityDescriptor = entityDescriptor; this.sessionFactory = entityDescriptor.getEntityPersister().getFactory(); - final int numberOfColumns = entityDescriptor.getIdentifierMapping().getJdbcTypeCount( bootstrapContext.getTypeConfiguration() ); + final int numberOfColumns = entityDescriptor.getIdentifierMapping().getJdbcTypeCount( runtimeModelCreationContext.getTypeConfiguration() ); cteColumns = new ArrayList<>( numberOfColumns ); entityDescriptor.getIdentifierMapping().visitColumns( (columnExpression, containingTableExpression, jdbcMapping) -> cteColumns.add( diff --git a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/MappedFetchTests.java b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/MappedFetchTests.java index 6faf3e8705..bfddfb5440 100644 --- a/hibernate-core/src/test/java/org/hibernate/orm/test/loading/MappedFetchTests.java +++ b/hibernate-core/src/test/java/org/hibernate/orm/test/loading/MappedFetchTests.java @@ -164,9 +164,9 @@ public class MappedFetchTests { session -> session.doWork( connection -> { try ( Statement statement = connection.createStatement() ) { - statement.execute( "delete nick_names" ); - statement.execute( "delete simple_entity" ); - statement.execute( "delete root_entity" ); + statement.execute( "delete from nick_names" ); + statement.execute( "delete from simple_entity" ); + statement.execute( "delete from root_entity" ); } } )