diff --git a/bom/application/pom.xml b/bom/application/pom.xml
index 5aab0f122ef81..2fd555c7393ab 100644
--- a/bom/application/pom.xml
+++ b/bom/application/pom.xml
@@ -76,7 +76,7 @@
2.1.0
3.0.0
2.0.1
- 3.0.0
+ 3.1.0
6.0.0
2.0.1
3.0.2
@@ -97,9 +97,9 @@
3.12.0
1.15
1.5.1
- 5.6.15.Final
+ 6.2.0.CR2
1.12.18
- 5.1.2.Final
+ 6.0.6.Final
1.1.9.Final
8.0.0.Final
6.1.7.Final
@@ -127,7 +127,7 @@
4.1.5
9.2.0
2.3.2
-
2.1.214
+ 2.1.214
42.5.4
3.1.2
8.0.30
@@ -177,7 +177,7 @@
3.25.0
3.14.9
1.17.2
- 0.1.1
+ 0.2.0
4.5.1
5.2.SP7
2.1.SP2
@@ -5367,8 +5367,8 @@
${hibernate-validator.version}
- org.hibernate
- hibernate-core-jakarta
+ org.hibernate.orm
+ hibernate-core
${hibernate-orm.version}
@@ -5378,18 +5378,18 @@
- org.hibernate
+ org.hibernate.orm
hibernate-graalvm
${hibernate-orm.version}
- org.hibernate
- hibernate-envers-jakarta
+ org.hibernate.orm
+ hibernate-envers
${hibernate-orm.version}
- org.hibernate
- hibernate-jpamodelgen-jakarta
+ org.hibernate.orm
+ hibernate-jpamodelgen
${hibernate-orm.version}
@@ -5404,7 +5404,7 @@
org.hibernate
- quarkus-local-cache-jakarta
+ quarkus-local-cache
${hibernate-quarkus-local-cache.version}
@@ -5419,18 +5419,14 @@
org.hibernate.search
- hibernate-search-mapper-orm-coordination-outbox-polling-jakarta
+ hibernate-search-mapper-orm-coordination-outbox-polling-orm6
${hibernate-search.version}
org.hibernate.search
- hibernate-search-mapper-orm-jakarta
+ hibernate-search-mapper-orm-orm6
${hibernate-search.version}
-
- org.jboss
- jandex
-
org.hibernate.common
diff --git a/core/runtime/src/main/java/io/quarkus/runtime/graal/DisableLoggingFeature.java b/core/runtime/src/main/java/io/quarkus/runtime/graal/DisableLoggingFeature.java
index ced06e4972bb9..955884c00e8ac 100644
--- a/core/runtime/src/main/java/io/quarkus/runtime/graal/DisableLoggingFeature.java
+++ b/core/runtime/src/main/java/io/quarkus/runtime/graal/DisableLoggingFeature.java
@@ -1,6 +1,5 @@
package io.quarkus.runtime.graal;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
@@ -41,6 +40,6 @@ public void afterAnalysis(AfterAnalysisAccess access) {
@Override
public String getDescription() {
- return "Disables INFO logging during the analysis phase for the " + Arrays.toString(CATEGORIES) + " categories";
+ return "Disables INFO logging during the analysis phase";
}
}
diff --git a/docs/src/main/asciidoc/hibernate-orm-panache.adoc b/docs/src/main/asciidoc/hibernate-orm-panache.adoc
index 0b6a05d9a49f9..fd4ca25076670 100644
--- a/docs/src/main/asciidoc/hibernate-orm-panache.adoc
+++ b/docs/src/main/asciidoc/hibernate-orm-panache.adoc
@@ -627,9 +627,9 @@ If your select query does not start with `from`, we support the following additi
If your update query does not start with `update`, we support the following additional forms:
-- `from EntityName ...` which will expand to `update from EntityName ...`
-- `set? ` (and single parameter) which will expand to `update from EntityName set = ?`
-- `set? ` will expand to `update from EntityName set `
+- `from EntityName ...` which will expand to `update EntityName ...`
+- `set? ` (and single parameter) which will expand to `update EntityName set = ?`
+- `set? ` will expand to `update EntityName set `
If your delete query does not start with `delete`, we support the following additional forms:
@@ -643,7 +643,7 @@ link:https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_Us
[source,java]
----
Order.find("select distinct o from Order o left join fetch o.lineItems");
-Order.update("update from Person set name = 'Mortal' where status = ?", Status.Alive);
+Order.update("update Person set name = 'Mortal' where status = ?", Status.Alive);
----
=== Named queries
diff --git a/extensions/hibernate-envers/deployment/src/main/java/io/quarkus/hibernate/envers/deployment/HibernateEnversProcessor.java b/extensions/hibernate-envers/deployment/src/main/java/io/quarkus/hibernate/envers/deployment/HibernateEnversProcessor.java
index 736accdc727f6..01b351c891fd5 100644
--- a/extensions/hibernate-envers/deployment/src/main/java/io/quarkus/hibernate/envers/deployment/HibernateEnversProcessor.java
+++ b/extensions/hibernate-envers/deployment/src/main/java/io/quarkus/hibernate/envers/deployment/HibernateEnversProcessor.java
@@ -8,10 +8,13 @@
import io.quarkus.deployment.annotations.BuildSteps;
import io.quarkus.deployment.annotations.ExecutionTime;
import io.quarkus.deployment.annotations.Record;
+import io.quarkus.deployment.builditem.NativeImageFeatureBuildItem;
import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
+import io.quarkus.deployment.pkg.steps.NativeOrNativeSourcesBuild;
import io.quarkus.hibernate.envers.HibernateEnversBuildTimeConfig;
import io.quarkus.hibernate.envers.HibernateEnversBuildTimeConfigPersistenceUnit;
import io.quarkus.hibernate.envers.HibernateEnversRecorder;
+import io.quarkus.hibernate.envers.runtime.graal.DisableLoggingFeature;
import io.quarkus.hibernate.orm.deployment.AdditionalJpaModelBuildItem;
import io.quarkus.hibernate.orm.deployment.PersistenceUnitDescriptorBuildItem;
import io.quarkus.hibernate.orm.deployment.integration.HibernateOrmIntegrationStaticConfiguredBuildItem;
@@ -34,10 +37,6 @@ public void registerEnversReflections(BuildProducer re
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false, "org.hibernate.envers.DefaultRevisionEntity"));
reflectiveClass.produce(new ReflectiveClassBuildItem(true, false,
"org.hibernate.envers.DefaultTrackingModifiedEntitiesRevisionEntity"));
- reflectiveClass
- .produce(new ReflectiveClassBuildItem(false, false, "org.hibernate.tuple.entity.DynamicMapEntityTuplizer"));
- reflectiveClass.produce(
- new ReflectiveClassBuildItem(false, false, "org.hibernate.tuple.component.DynamicMapComponentTuplizer"));
for (HibernateEnversBuildTimeConfigPersistenceUnit pu : buildTimeConfig.getAllPersistenceUnitConfigsAsMap().values()) {
pu.revisionListener.ifPresent(s -> reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, s)));
@@ -45,6 +44,11 @@ public void registerEnversReflections(BuildProducer re
}
}
+ @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
+ NativeImageFeatureBuildItem nativeImageFeature() {
+ return new NativeImageFeatureBuildItem(DisableLoggingFeature.class);
+ }
+
@BuildStep
@Record(ExecutionTime.STATIC_INIT)
public void applyStaticConfig(HibernateEnversRecorder recorder, HibernateEnversBuildTimeConfig buildTimeConfig,
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/AbstractEnversResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/AbstractEnversResource.java
index c784bb37fa34d..40c7c8839dac2 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/AbstractEnversResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/AbstractEnversResource.java
@@ -4,11 +4,11 @@
import jakarta.persistence.EntityManager;
import jakarta.transaction.UserTransaction;
+import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.envers.boot.internal.EnversService;
-import org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration;
-import org.hibernate.envers.configuration.internal.GlobalConfiguration;
+import org.hibernate.envers.configuration.Configuration;
+import org.hibernate.envers.internal.entities.EntitiesConfigurations;
import org.hibernate.envers.strategy.AuditStrategy;
-import org.hibernate.internal.SessionImpl;
import org.hibernate.persister.entity.EntityPersister;
public abstract class AbstractEnversResource {
@@ -23,15 +23,16 @@ public String getDefaultAuditEntityName(Class> clazz) {
}
public EntityPersister getEntityPersister(String entityName) {
- return ((SessionImpl) em.getDelegate()).getSessionFactory().getMetamodel().entityPersister(entityName);
+ return ((SessionImplementor) em.getDelegate()).getSessionFactory().getMappingMetamodel()
+ .findEntityDescriptor(entityName);
}
- public AuditEntitiesConfiguration getAuditEntitiesConfiguration() {
- return getEnversService().getAuditEntitiesConfiguration();
+ public EntitiesConfigurations getEntitiesConfiguration() {
+ return getEnversService().getEntitiesConfigurations();
}
- public GlobalConfiguration getGlobalConfiguration() {
- return getEnversService().getGlobalConfiguration();
+ public Configuration getConfiguration() {
+ return getEnversService().getConfig();
}
public AuditStrategy getAuditStrategy() {
@@ -39,7 +40,7 @@ public AuditStrategy getAuditStrategy() {
}
public EnversService getEnversService() {
- return ((((SessionImpl) em.getDelegate()).getFactory().getServiceRegistry())
+ return ((((SessionImplementor) em.getDelegate()).getFactory().getServiceRegistry())
.getParentServiceRegistry())
.getService(EnversService.class);
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversConfigurationPerPUTest.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversConfigurationPerPUTest.java
index b19f5066bac18..5bf028415a4a3 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversConfigurationPerPUTest.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversConfigurationPerPUTest.java
@@ -7,7 +7,7 @@
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.envers.boot.internal.EnversService;
-import org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration;
+import org.hibernate.envers.configuration.Configuration;
import org.hibernate.internal.SessionFactoryImpl;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -36,44 +36,44 @@ public class EnversConfigurationPerPUTest {
@Test
public void testTableName() {
- String generatedTableName = getAuditConfiguration(emf).getAuditTableName("entity", "table");
+ String generatedTableName = getConfiguration(emf).getAuditTableName("entity", "table");
assertThat(generatedTableName).isEqualTo("P_table");
- generatedTableName = getAuditConfiguration(emf1).getAuditTableName("entity", "table");
+ generatedTableName = getConfiguration(emf1).getAuditTableName("entity", "table");
assertThat(generatedTableName).isEqualTo("T_table");
- generatedTableName = getAuditConfiguration(emf2).getAuditTableName("entity", "table");
+ generatedTableName = getConfiguration(emf2).getAuditTableName("entity", "table");
assertThat(generatedTableName).isEqualTo("R_table");
}
@Test
public void testRevisionFieldName() {
- String configuredRevisionFieldName = getAuditConfiguration(emf).getRevisionFieldName();
+ String configuredRevisionFieldName = getConfiguration(emf).getRevisionFieldName();
assertThat(configuredRevisionFieldName).isEqualTo("GEN");
- configuredRevisionFieldName = getAuditConfiguration(emf1).getRevisionFieldName();
+ configuredRevisionFieldName = getConfiguration(emf1).getRevisionFieldName();
assertThat(configuredRevisionFieldName).isEqualTo("REVISION");
- configuredRevisionFieldName = getAuditConfiguration(emf2).getRevisionFieldName();
+ configuredRevisionFieldName = getConfiguration(emf2).getRevisionFieldName();
assertThat(configuredRevisionFieldName).isEqualTo("REV");
}
@Test
public void testRevisionTypeName() {
- String configuredRevisionTypeName = getAuditConfiguration(emf).getRevisionTypePropName();
+ String configuredRevisionTypeName = getConfiguration(emf).getRevisionTypePropertyName();
assertThat(configuredRevisionTypeName).isEqualTo("GEN_TYPE");
- configuredRevisionTypeName = getAuditConfiguration(emf1).getRevisionTypePropName();
+ configuredRevisionTypeName = getConfiguration(emf1).getRevisionTypePropertyName();
assertThat(configuredRevisionTypeName).isEqualTo("REV_TYPE");
- configuredRevisionTypeName = getAuditConfiguration(emf2).getRevisionTypePropName();
+ configuredRevisionTypeName = getConfiguration(emf2).getRevisionTypePropertyName();
assertThat(configuredRevisionTypeName).isEqualTo("REVTYPE");
}
- private AuditEntitiesConfiguration getAuditConfiguration(EntityManagerFactory emf) {
+ private Configuration getConfiguration(EntityManagerFactory emf) {
return ((((SessionFactoryImplementor) emf
.unwrap(SessionFactoryImpl.class))
.getServiceRegistry()).getParentServiceRegistry())
- .getService(EnversService.class).getAuditEntitiesConfiguration();
+ .getService(EnversService.class).getConfig();
}
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversConfigurationTest.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversConfigurationTest.java
index 155a3f5eab2fa..d29f5ed64e826 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversConfigurationTest.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversConfigurationTest.java
@@ -7,7 +7,7 @@
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.envers.boot.internal.EnversService;
-import org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration;
+import org.hibernate.envers.configuration.Configuration;
import org.hibernate.internal.SessionFactoryImpl;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.RegisterExtension;
@@ -27,26 +27,26 @@ public class EnversConfigurationTest {
@Test
public void testTableName() {
- String generatedTableName = getAuditConfiguration().getAuditTableName("entity", "table");
+ String generatedTableName = getConfiguration().getAuditTableName("entity", "table");
assertThat(generatedTableName).isEqualTo("P_table");
}
@Test
public void testRevisionFieldName() {
- String configuredRevisionFieldName = getAuditConfiguration().getRevisionFieldName();
+ String configuredRevisionFieldName = getConfiguration().getRevisionFieldName();
assertThat(configuredRevisionFieldName).isEqualTo("GEN");
}
@Test
public void testRevisionTypeName() {
- String configuredRevisionTypeName = getAuditConfiguration().getRevisionTypePropName();
+ String configuredRevisionTypeName = getConfiguration().getRevisionTypePropertyName();
assertThat(configuredRevisionTypeName).isEqualTo("GEN_TYPE");
}
- private AuditEntitiesConfiguration getAuditConfiguration() {
+ private Configuration getConfiguration() {
return ((((SessionFactoryImplementor) emf
.unwrap(SessionFactoryImpl.class))
.getServiceRegistry()).getParentServiceRegistry())
- .getService(EnversService.class).getAuditEntitiesConfiguration();
+ .getService(EnversService.class).getConfig();
}
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversTestAuditTableSuffixResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversTestAuditTableSuffixResource.java
index 54de9dd23f690..ca4a2f3464ccb 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversTestAuditTableSuffixResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/EnversTestAuditTableSuffixResource.java
@@ -8,7 +8,7 @@
import org.eclipse.microprofile.config.inject.ConfigProperty;
import org.hibernate.envers.boot.internal.EnversService;
-import org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration;
+import org.hibernate.envers.configuration.Configuration;
import org.hibernate.internal.SessionImpl;
@Path("/audit-table-suffix")
@@ -24,9 +24,9 @@ public class EnversTestAuditTableSuffixResource {
@GET
public String getAuditTableName() {
- AuditEntitiesConfiguration auditEntitiesConfiguration = ((((SessionImpl) em.getDelegate())
+ Configuration auditEntitiesConfiguration = ((((SessionImpl) em.getDelegate())
.getFactory().getServiceRegistry()).getParentServiceRegistry())
- .getService(EnversService.class).getAuditEntitiesConfiguration();
+ .getService(EnversService.class).getConfig();
String calculatedAuditTableName = auditEntitiesConfiguration.getAuditTableName("entity", "table");
String expectedAuditTableName = "table" + configuredSuffix;
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestAllowIdentifierReuseResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestAllowIdentifierReuseResource.java
index ec292e5af92e1..fe17aaf2049b2 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestAllowIdentifierReuseResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestAllowIdentifierReuseResource.java
@@ -12,7 +12,7 @@
public class EnversTestAllowIdentifierReuseResource extends AbstractEnversResource {
@GET
public String getAllowIdentifierReuse() {
- boolean identifierReuse = getGlobalConfiguration().isAllowIdentifierReuse();
+ boolean identifierReuse = getConfiguration().isAllowIdentifierReuse();
if (!identifierReuse) {
return "Expected allow_identifier_reuse to be true but was false";
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestDefaultSchemaCatalogResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestDefaultSchemaCatalogResource.java
index 3561af8b27764..dc4cecfc29eb1 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestDefaultSchemaCatalogResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestDefaultSchemaCatalogResource.java
@@ -12,12 +12,12 @@
public class EnversTestDefaultSchemaCatalogResource extends AbstractEnversResource {
@GET
public String getDefaultSchemaAndCatalog() {
- String defaultSchema = getGlobalConfiguration().getDefaultSchemaName();
+ String defaultSchema = getConfiguration().getDefaultSchemaName();
if (!"public".equals(defaultSchema)) {
return "Expected default_schema to be public but was: " + defaultSchema;
}
- String defaultCatalog = getGlobalConfiguration().getDefaultCatalogName();
+ String defaultCatalog = getConfiguration().getDefaultCatalogName();
if (!"".equals(defaultCatalog)) {
return "Expected default_catalog to be an empty string but was: " + defaultCatalog;
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestDoNotAuditOptimisticLockingFieldResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestDoNotAuditOptimisticLockingFieldResource.java
index 160b2a505cf93..5bdd321b79e82 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestDoNotAuditOptimisticLockingFieldResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestDoNotAuditOptimisticLockingFieldResource.java
@@ -15,7 +15,7 @@
public class EnversTestDoNotAuditOptimisticLockingFieldResource extends AbstractEnversResource {
@GET
public String getDoNotAuditOptimisticLockingFieldDisabled() {
- if (!getGlobalConfiguration().isDoNotAuditOptimisticLockingField()) {
+ if (!getConfiguration().isDoNotAuditOptimisticLockingField()) {
EntityPersister persister = getEntityPersister(MyAuditedVersionEntity.class.getName() + "_AUD");
for (String propertyName : persister.getPropertyNames()) {
if (propertyName.equals("version")) {
@@ -23,6 +23,6 @@ public String getDoNotAuditOptimisticLockingFieldDisabled() {
}
}
}
- return "Expected false is not as expected: " + getGlobalConfiguration().isDoNotAuditOptimisticLockingField();
+ return "Expected false is not as expected: " + getConfiguration().isDoNotAuditOptimisticLockingField();
}
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestEmbeddableSetOrdinalFieldNameResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestEmbeddableSetOrdinalFieldNameResource.java
index 2eea17a75e150..7ec0bdb78f2e3 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestEmbeddableSetOrdinalFieldNameResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestEmbeddableSetOrdinalFieldNameResource.java
@@ -12,7 +12,7 @@
public class EnversTestEmbeddableSetOrdinalFieldNameResource extends AbstractEnversResource {
@GET
public String getEntityWithEmbeddableSetMappingNameOverride() {
- String embeddableSetOrdinalName = getAuditEntitiesConfiguration().getEmbeddableSetOrdinalPropertyName();
+ String embeddableSetOrdinalName = getConfiguration().getEmbeddableSetOrdinalPropertyName();
if (embeddableSetOrdinalName.equals("ORD")) {
return "OK";
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestModifiedColumnNamingStrategyResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestModifiedColumnNamingStrategyResource.java
index 1b11d33a2b452..ff429060712a7 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestModifiedColumnNamingStrategyResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestModifiedColumnNamingStrategyResource.java
@@ -15,7 +15,7 @@ public class EnversTestModifiedColumnNamingStrategyResource extends AbstractEnve
@GET
public String getModifiedNamingStrategy() {
Class> expectedClass = ImprovedModifiedColumnNamingStrategy.class;
- Class> actualClass = getGlobalConfiguration().getModifiedColumnNamingStrategy().getClass();
+ Class> actualClass = getConfiguration().getModifiedColumnNamingStrategy().getClass();
if (actualClass.equals(expectedClass)) {
return "OK";
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestModifiedFlagsResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestModifiedFlagsResource.java
index afcd5f6955064..f8063186c9a19 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestModifiedFlagsResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestModifiedFlagsResource.java
@@ -12,14 +12,14 @@
public class EnversTestModifiedFlagsResource extends AbstractEnversResource {
@GET
public String getModifiedFlags() {
- boolean globalWithModifiedFlags = getGlobalConfiguration().isGlobalWithModifiedFlag();
+ boolean globalWithModifiedFlags = getConfiguration().isModifiedFlagsEnabled();
if (!globalWithModifiedFlags) {
return "Expected global_with_modified_flag to be true but was false";
}
- String modifiedFlagSuffix = getGlobalConfiguration().getModifiedFlagSuffix();
- if (!"_changed".equals(modifiedFlagSuffix)) {
- return "Expected modified_flag_suffix to be _changed but was: " + modifiedFlagSuffix;
+ String modifiedFlagsSuffix = getConfiguration().getModifiedFlagsSuffix();
+ if (!"_changed".equals(modifiedFlagsSuffix)) {
+ return "Expected modified_flag_suffix to be _changed but was: " + modifiedFlagsSuffix;
}
return "OK";
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestOriginalIdPropNameResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestOriginalIdPropNameResource.java
index 68aa00d195ebb..d0ec884245086 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestOriginalIdPropNameResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestOriginalIdPropNameResource.java
@@ -15,7 +15,7 @@
public class EnversTestOriginalIdPropNameResource extends AbstractEnversResource {
@GET
public String getOriginalIdPropNameOverride() {
- String originalIdFieldName = getAuditEntitiesConfiguration().getOriginalIdPropName();
+ String originalIdFieldName = getConfiguration().getOriginalIdPropertyName();
if (!originalIdFieldName.equals("oid")) {
return "Expected original_id_prop_name to be oid but was: " + originalIdFieldName;
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestRevisionListenerResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestRevisionListenerResource.java
index 8c5ec1c1a570d..4ae830a98f410 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestRevisionListenerResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestRevisionListenerResource.java
@@ -23,7 +23,7 @@ public class EnversTestRevisionListenerResource extends AbstractEnversResource {
@GET
public String getRevisionListener() {
Class> expectedClass = MyListenerlessRevisionListener.class;
- Class> listenerClass = getGlobalConfiguration().getRevisionListenerClass();
+ Class> listenerClass = getConfiguration().getRevisionListenerClass();
if (listenerClass.equals(expectedClass)) {
try {
transaction.begin();
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestRevisionOnCollectionChangeResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestRevisionOnCollectionChangeResource.java
index 9406e1dbba828..78e3549d21be4 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestRevisionOnCollectionChangeResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestRevisionOnCollectionChangeResource.java
@@ -12,7 +12,7 @@
public class EnversTestRevisionOnCollectionChangeResource extends AbstractEnversResource {
@GET
public String getRevisionOnCollectionChange() {
- boolean revisionsForCollections = getGlobalConfiguration().isGenerateRevisionsForCollections();
+ boolean revisionsForCollections = getConfiguration().isGenerateRevisionsForCollections();
if (revisionsForCollections) {
return "Expected revision_on_collect_change to be false but was true";
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestTrackEntitiesChangedInRevisionResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestTrackEntitiesChangedInRevisionResource.java
index 6a26e6abeff4c..354380835ba44 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestTrackEntitiesChangedInRevisionResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestTrackEntitiesChangedInRevisionResource.java
@@ -12,7 +12,7 @@
public class EnversTestTrackEntitiesChangedInRevisionResource extends AbstractEnversResource {
@GET
public String getTrackEntitiesChangedInRevision() {
- boolean trackEntityChangesInRevision = getGlobalConfiguration().isTrackEntitiesChangedInRevision();
+ boolean trackEntityChangesInRevision = getConfiguration().isTrackEntitiesChanged();
if (!trackEntityChangesInRevision) {
return "Expected track_entities_changed_in_revision to be true but was false";
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestUseRevisionEntityWithNativeIdResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestUseRevisionEntityWithNativeIdResource.java
index 2330d358cfb87..318414ffa5350 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestUseRevisionEntityWithNativeIdResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestUseRevisionEntityWithNativeIdResource.java
@@ -12,7 +12,7 @@
public class EnversTestUseRevisionEntityWithNativeIdResource extends AbstractEnversResource {
@GET
public String getUseRevisionEntityWithNativeId() {
- boolean revisionEntityWithNativeId = getGlobalConfiguration().isUseRevisionEntityWithNativeId();
+ boolean revisionEntityWithNativeId = getConfiguration().isNativeIdEnabled();
if (revisionEntityWithNativeId) {
return "Expected use_revision_entity_with_native_id to be false but was true";
}
diff --git a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestValidityStrategyFieldNameOverridesResource.java b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestValidityStrategyFieldNameOverridesResource.java
index c6149be97b802..5e9a2594adb7c 100644
--- a/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestValidityStrategyFieldNameOverridesResource.java
+++ b/extensions/hibernate-envers/deployment/src/test/java/io/quarkus/hibernate/orm/envers/config/EnversTestValidityStrategyFieldNameOverridesResource.java
@@ -12,17 +12,17 @@
public class EnversTestValidityStrategyFieldNameOverridesResource extends AbstractEnversResource {
@GET
public String getValidityStrategyFieldNameOverrides() {
- boolean isRevEndTimestampIncluded = getAuditEntitiesConfiguration().isRevisionEndTimestampEnabled();
+ boolean isRevEndTimestampIncluded = getConfiguration().isRevisionEndTimestampEnabled();
if (!isRevEndTimestampIncluded) {
return "Expected audit_strategy_validity_store_revend_timestamp to be true but was false";
}
- String revEndFieldName = getAuditEntitiesConfiguration().getRevisionEndFieldName();
+ String revEndFieldName = getConfiguration().getRevisionEndFieldName();
if (!revEndFieldName.equals("REV_END")) {
return "Expected audit_strategy_validity_end_rev_field_name to be REV_END but was: " + revEndFieldName;
}
- String revEndTimestampFieldName = getAuditEntitiesConfiguration().getRevisionEndTimestampFieldName();
+ String revEndTimestampFieldName = getConfiguration().getRevisionEndTimestampFieldName();
if (!revEndTimestampFieldName.equals("REV_END_TSTMP")) {
return "Expected audit_strategy_validity_revend_timestamp_field_name to be REV_END_TSTMP but was: "
+ revEndTimestampFieldName;
diff --git a/extensions/hibernate-envers/runtime/pom.xml b/extensions/hibernate-envers/runtime/pom.xml
index 700f9c46af6b2..024c1a6b1e649 100644
--- a/extensions/hibernate-envers/runtime/pom.xml
+++ b/extensions/hibernate-envers/runtime/pom.xml
@@ -16,24 +16,11 @@
- org.hibernate
- hibernate-envers-jakarta
+ org.hibernate.orm
+ hibernate-envers
-
- javax.persistence
- javax.persistence-api
-
-
- org.jboss.spec.javax.transaction
- jboss-transaction-api_1.2_spec
-
-
-
- javax.xml.bind
- jaxb-api
-
org.glassfish.jaxb
jaxb-runtime
@@ -44,10 +31,6 @@
jakarta.activation
jakarta.activation-api
-
- javax.activation
- javax.activation-api
-
diff --git a/extensions/hibernate-envers/runtime/src/main/java/io/quarkus/hibernate/envers/runtime/graal/DisableLoggingFeature.java b/extensions/hibernate-envers/runtime/src/main/java/io/quarkus/hibernate/envers/runtime/graal/DisableLoggingFeature.java
new file mode 100644
index 0000000000000..de6d22b94c1a6
--- /dev/null
+++ b/extensions/hibernate-envers/runtime/src/main/java/io/quarkus/hibernate/envers/runtime/graal/DisableLoggingFeature.java
@@ -0,0 +1,46 @@
+package io.quarkus.hibernate.envers.runtime.graal;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import org.graalvm.nativeimage.hosted.Feature;
+
+/**
+ * Disables logging during the analysis phase
+ */
+public class DisableLoggingFeature implements Feature {
+
+ private static final String[] CATEGORIES = {
+ "org.hibernate.envers.boot.internal.EnversServiceImpl",
+ "org.hibernate.envers.configuration.internal.metadata.AuditMetadataGenerator"
+ };
+
+ private final Map categoryMap = new HashMap<>(CATEGORIES.length);
+
+ @Override
+ public void beforeAnalysis(BeforeAnalysisAccess access) {
+ for (String category : CATEGORIES) {
+ Logger logger = Logger.getLogger(category);
+ categoryMap.put(category, logger.getLevel());
+ logger.setLevel(Level.WARNING);
+ }
+ }
+
+ @Override
+ public void afterAnalysis(AfterAnalysisAccess access) {
+ for (String category : CATEGORIES) {
+ Level level = categoryMap.remove(category);
+ if (level != null) {
+ Logger logger = Logger.getLogger(category);
+ logger.setLevel(level);
+ }
+ }
+ }
+
+ @Override
+ public String getDescription() {
+ return "Disables INFO logging during the analysis phase";
+ }
+}
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ClassNames.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ClassNames.java
index c48d6bba53428..ad507f61870d4 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ClassNames.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/ClassNames.java
@@ -39,16 +39,14 @@ private static DotName createConstant(String fqcn) {
public static final DotName JPA_ENTITY = createConstant("jakarta.persistence.Entity");
public static final DotName MAPPED_SUPERCLASS = createConstant("jakarta.persistence.MappedSuperclass");
public static final DotName EMBEDDABLE = createConstant("jakarta.persistence.Embeddable");
+ public static final DotName ID_CLASS = createConstant("jakarta.persistence.IdClass");
public static final DotName CONVERTER = createConstant("jakarta.persistence.Converter");
public static final DotName EMBEDDED = createConstant("jakarta.persistence.Embedded");
public static final DotName ELEMENT_COLLECTION = createConstant("jakarta.persistence.ElementCollection");
public static final DotName PROXY = createConstant("org.hibernate.annotations.Proxy");
public static final DotName HIBERNATE_PROXY = createConstant("org.hibernate.proxy.HibernateProxy");
public static final DotName TYPE = createConstant("org.hibernate.annotations.Type");
- public static final DotName TYPE_DEFINITION = createConstant("org.hibernate.annotations.TypeDef");
- public static final DotName TYPE_DEFINITIONS = createConstant("org.hibernate.annotations.TypeDefs");
public static final DotName INJECT_SERVICE = createConstant("org.hibernate.service.spi.InjectService");
-
public static final DotName ENTITY_MANAGER_FACTORY = createConstant("jakarta.persistence.EntityManagerFactory");
public static final DotName SESSION_FACTORY = createConstant("org.hibernate.SessionFactory");
public static final DotName ENTITY_MANAGER = createConstant("jakarta.persistence.EntityManager");
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/GraalVMFeatures.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/GraalVMFeatures.java
index faee479dab034..8623c4668d98c 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/GraalVMFeatures.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/GraalVMFeatures.java
@@ -16,9 +16,4 @@ NativeImageFeatureBuildItem staticNativeImageFeature() {
return new NativeImageFeatureBuildItem("org.hibernate.graalvm.internal.GraalVMStaticFeature");
}
- @BuildStep
- NativeImageFeatureBuildItem queryParsingSupportFeature() {
- return new NativeImageFeatureBuildItem("org.hibernate.graalvm.internal.QueryParsingSupport");
- }
-
}
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateLogFilterBuildStep.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateLogFilterBuildStep.java
index 35710e943e88f..b5549222fa7ab 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateLogFilterBuildStep.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateLogFilterBuildStep.java
@@ -22,24 +22,10 @@ NativeImageFeatureBuildItem nativeImageFeature() {
@BuildStep
void setupLogFilters(BuildProducer filters) {
filters.produce(new LogCleanupFilterBuildItem("org.hibernate.Version", "HHH000412"));
- filters.produce(new LogCleanupFilterBuildItem("org.hibernate.cfg.Environment", "HHH000206"));
- filters.produce(new LogCleanupFilterBuildItem("org.hibernate.bytecode.enhance.spi.Enhancer", "Enhancing [%s] as"));
- filters.produce(new LogCleanupFilterBuildItem(
- "org.hibernate.bytecode.enhance.internal.bytebuddy.BiDirectionalAssociationHandler", "Could not find"));
+ //Disable details about bytecode reflection optimizer:
+ filters.produce(new LogCleanupFilterBuildItem("org.hibernate.cfg.Environment", "HHH000406"));
filters.produce(new LogCleanupFilterBuildItem("org.hibernate.jpa.internal.util.LogHelper", "HHH000204"));
- filters.produce(new LogCleanupFilterBuildItem("org.hibernate.annotations.common.Version", "HCANN000001"));
- filters.produce(
- new LogCleanupFilterBuildItem("org.hibernate.engine.jdbc.env.internal.LobCreatorBuilderImpl", "HHH000422"));
- filters.produce(new LogCleanupFilterBuildItem("org.hibernate.dialect.Dialect", "HHH000400"));
- filters.produce(new LogCleanupFilterBuildItem("org.hibernate.type.BasicTypeRegistry", "HHH000270"));
+ filters.produce(new LogCleanupFilterBuildItem("SQL dialect", "HHH000400"));
filters.produce(new LogCleanupFilterBuildItem("org.hibernate.orm.beans", "HHH10005002", "HHH10005004"));
- filters.produce(new LogCleanupFilterBuildItem("org.hibernate.tuple.PojoInstantiator", "HHH000182"));
- filters.produce(new LogCleanupFilterBuildItem("org.hibernate.tuple.entity.EntityMetamodel", "HHH000157"));
- filters.produce(new LogCleanupFilterBuildItem(
- "org.hibernate.engine.transaction.jta.platform.internal.JtaPlatformInitiator", "HHH000490"));
- filters.produce(new LogCleanupFilterBuildItem("org.hibernate.tool.schema.internal.SchemaCreatorImpl", "HHH000476"));
- filters.produce(
- new LogCleanupFilterBuildItem("org.hibernate.hql.internal.QueryTranslatorFactoryInitiator", "HHH000397"));
- filters.produce(new LogCleanupFilterBuildItem("org.hibernate.jpa.boot.internal.PersistenceXmlParser", "HHH000318"));
}
}
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmAnnotations.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmAnnotations.java
index bc4c30f2646d8..384b8239753c3 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmAnnotations.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmAnnotations.java
@@ -10,8 +10,16 @@ private HibernateOrmAnnotations() {
}
public static final List PACKAGE_ANNOTATIONS = List.of(
- DotName.createSimple("org.hibernate.annotations.AnyMetaDef"),
- DotName.createSimple("org.hibernate.annotations.AnyMetaDefs"),
+ DotName.createSimple("org.hibernate.annotations.CollectionTypeRegistration"),
+ DotName.createSimple("org.hibernate.annotations.CompositeTypeRegistration"),
+ DotName.createSimple("org.hibernate.annotations.CompositeTypeRegistrations"),
+ DotName.createSimple("org.hibernate.annotations.ConverterRegistration"),
+ DotName.createSimple("org.hibernate.annotations.ConverterRegistrations"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$FilterDefOverrides"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$FilterDefs"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$Version"),
+ DotName.createSimple("org.hibernate.annotations.EmbeddableInstantiatorRegistration"),
+ DotName.createSimple("org.hibernate.annotations.EmbeddableInstantiatorRegistrations"),
DotName.createSimple("org.hibernate.annotations.FetchProfile"),
DotName.createSimple("org.hibernate.annotations.FetchProfile$FetchOverride"),
DotName.createSimple("org.hibernate.annotations.FetchProfiles"),
@@ -19,13 +27,17 @@ private HibernateOrmAnnotations() {
DotName.createSimple("org.hibernate.annotations.FilterDefs"),
DotName.createSimple("org.hibernate.annotations.GenericGenerator"),
DotName.createSimple("org.hibernate.annotations.GenericGenerators"),
+ DotName.createSimple("org.hibernate.annotations.JavaTypeRegistration"),
+ DotName.createSimple("org.hibernate.annotations.JavaTypeRegistrations"),
+ DotName.createSimple("org.hibernate.annotations.JdbcTypeRegistration"),
+ DotName.createSimple("org.hibernate.annotations.JdbcTypeRegistrations"),
DotName.createSimple("org.hibernate.annotations.ListIndexBase"),
DotName.createSimple("org.hibernate.annotations.NamedNativeQueries"),
DotName.createSimple("org.hibernate.annotations.NamedNativeQuery"),
DotName.createSimple("org.hibernate.annotations.NamedQueries"),
DotName.createSimple("org.hibernate.annotations.NamedQuery"),
- DotName.createSimple("org.hibernate.annotations.TypeDef"),
- DotName.createSimple("org.hibernate.annotations.TypeDefs"));
+ DotName.createSimple("org.hibernate.annotations.TypeRegistration"),
+ DotName.createSimple("org.hibernate.annotations.TypeRegistrations"));
public static final List JPA_MAPPING_ANNOTATIONS = List.of(
DotName.createSimple("jakarta.persistence.Access"),
@@ -121,28 +133,73 @@ private HibernateOrmAnnotations() {
DotName.createSimple("jakarta.persistence.Version"));
public static final List HIBERNATE_MAPPING_ANNOTATIONS = List.of(
- DotName.createSimple("org.hibernate.annotations.AccessType"),
DotName.createSimple("org.hibernate.annotations.Any"),
- DotName.createSimple("org.hibernate.annotations.AnyMetaDef"),
- DotName.createSimple("org.hibernate.annotations.AnyMetaDefs"),
+ DotName.createSimple("org.hibernate.annotations.AnyDiscriminator"),
+ DotName.createSimple("org.hibernate.annotations.AnyDiscriminatorValue"),
+ DotName.createSimple("org.hibernate.annotations.AnyDiscriminatorValues"),
+ DotName.createSimple("org.hibernate.annotations.AnyKeyJavaClass"),
+ DotName.createSimple("org.hibernate.annotations.AnyKeyJavaType"),
+ DotName.createSimple("org.hibernate.annotations.AnyKeyJdbcType"),
+ DotName.createSimple("org.hibernate.annotations.AnyKeyJdbcTypeCode"),
DotName.createSimple("org.hibernate.annotations.AttributeAccessor"),
+ DotName.createSimple("org.hibernate.annotations.AttributeBinderType"),
+ DotName.createSimple("org.hibernate.annotations.Bag"),
DotName.createSimple("org.hibernate.annotations.BatchSize"),
DotName.createSimple("org.hibernate.annotations.Cache"),
DotName.createSimple("org.hibernate.annotations.Cascade"),
DotName.createSimple("org.hibernate.annotations.Check"),
+ DotName.createSimple("org.hibernate.annotations.Checks"),
DotName.createSimple("org.hibernate.annotations.CollectionId"),
+ DotName.createSimple("org.hibernate.annotations.CollectionIdJavaType"),
+ DotName.createSimple("org.hibernate.annotations.CollectionIdJdbcType"),
+ DotName.createSimple("org.hibernate.annotations.CollectionIdJdbcTypeCode"),
+ DotName.createSimple("org.hibernate.annotations.CollectionIdMutability"),
+ DotName.createSimple("org.hibernate.annotations.CollectionIdType"),
DotName.createSimple("org.hibernate.annotations.CollectionType"),
+ DotName.createSimple("org.hibernate.annotations.CollectionTypeRegistration"),
+ DotName.createSimple("org.hibernate.annotations.CollectionTypeRegistrations"),
DotName.createSimple("org.hibernate.annotations.ColumnDefault"),
DotName.createSimple("org.hibernate.annotations.ColumnTransformer"),
DotName.createSimple("org.hibernate.annotations.ColumnTransformers"),
DotName.createSimple("org.hibernate.annotations.Columns"),
DotName.createSimple("org.hibernate.annotations.Comment"),
+ DotName.createSimple("org.hibernate.annotations.Comments"),
+ DotName.createSimple("org.hibernate.annotations.CompositeType"),
+ DotName.createSimple("org.hibernate.annotations.CompositeTypeRegistration"),
+ DotName.createSimple("org.hibernate.annotations.CompositeTypeRegistrations"),
+ DotName.createSimple("org.hibernate.annotations.ConverterRegistration"),
+ DotName.createSimple("org.hibernate.annotations.ConverterRegistrations"),
DotName.createSimple("org.hibernate.annotations.CreationTimestamp"),
+ DotName.createSimple("org.hibernate.annotations.CurrentTimestamp"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$Check"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$Checks"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$ColumnDefault"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$ColumnDefaults"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$DiscriminatorFormula"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$DiscriminatorFormulas"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$FilterDefOverrides"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$FilterDefs"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$FilterOverrides"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$Filters"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$Formula"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$Formulas"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$GeneratedColumn"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$GeneratedColumns"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$JoinFormula"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$JoinFormulas"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$OrderBy"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$OrderBys"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$OverridesAnnotation"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$Version"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$Where"),
+ DotName.createSimple("org.hibernate.annotations.DialectOverride$Wheres"),
DotName.createSimple("org.hibernate.annotations.DiscriminatorFormula"),
DotName.createSimple("org.hibernate.annotations.DiscriminatorOptions"),
DotName.createSimple("org.hibernate.annotations.DynamicInsert"),
DotName.createSimple("org.hibernate.annotations.DynamicUpdate"),
- DotName.createSimple("org.hibernate.annotations.Entity"),
+ DotName.createSimple("org.hibernate.annotations.EmbeddableInstantiator"),
+ DotName.createSimple("org.hibernate.annotations.EmbeddableInstantiatorRegistration"),
+ DotName.createSimple("org.hibernate.annotations.EmbeddableInstantiatorRegistrations"),
DotName.createSimple("org.hibernate.annotations.Fetch"),
DotName.createSimple("org.hibernate.annotations.FetchProfile"),
DotName.createSimple("org.hibernate.annotations.FetchProfile$FetchOverride"),
@@ -156,12 +213,24 @@ private HibernateOrmAnnotations() {
DotName.createSimple("org.hibernate.annotations.ForeignKey"),
DotName.createSimple("org.hibernate.annotations.Formula"),
DotName.createSimple("org.hibernate.annotations.Generated"),
+ DotName.createSimple("org.hibernate.annotations.GeneratedColumn"),
DotName.createSimple("org.hibernate.annotations.GeneratorType"),
DotName.createSimple("org.hibernate.annotations.GenericGenerator"),
DotName.createSimple("org.hibernate.annotations.GenericGenerators"),
+ DotName.createSimple("org.hibernate.annotations.HQLSelect"),
+ DotName.createSimple("org.hibernate.annotations.IdGeneratorType"),
DotName.createSimple("org.hibernate.annotations.Immutable"),
+ DotName.createSimple("org.hibernate.annotations.Imported"),
DotName.createSimple("org.hibernate.annotations.Index"),
DotName.createSimple("org.hibernate.annotations.IndexColumn"),
+ DotName.createSimple("org.hibernate.annotations.Instantiator"),
+ DotName.createSimple("org.hibernate.annotations.JavaType"),
+ DotName.createSimple("org.hibernate.annotations.JavaTypeRegistration"),
+ DotName.createSimple("org.hibernate.annotations.JavaTypeRegistrations"),
+ DotName.createSimple("org.hibernate.annotations.JdbcType"),
+ DotName.createSimple("org.hibernate.annotations.JdbcTypeCode"),
+ DotName.createSimple("org.hibernate.annotations.JdbcTypeRegistration"),
+ DotName.createSimple("org.hibernate.annotations.JdbcTypeRegistrations"),
DotName.createSimple("org.hibernate.annotations.JoinColumnOrFormula"),
DotName.createSimple("org.hibernate.annotations.JoinColumnsOrFormulas"),
DotName.createSimple("org.hibernate.annotations.JoinFormula"),
@@ -169,9 +238,17 @@ private HibernateOrmAnnotations() {
DotName.createSimple("org.hibernate.annotations.LazyGroup"),
DotName.createSimple("org.hibernate.annotations.LazyToOne"),
DotName.createSimple("org.hibernate.annotations.ListIndexBase"),
+ DotName.createSimple("org.hibernate.annotations.ListIndexJavaType"),
+ DotName.createSimple("org.hibernate.annotations.ListIndexJdbcType"),
+ DotName.createSimple("org.hibernate.annotations.ListIndexJdbcTypeCode"),
DotName.createSimple("org.hibernate.annotations.Loader"),
DotName.createSimple("org.hibernate.annotations.ManyToAny"),
+ DotName.createSimple("org.hibernate.annotations.MapKeyJavaType"),
+ DotName.createSimple("org.hibernate.annotations.MapKeyJdbcType"),
+ DotName.createSimple("org.hibernate.annotations.MapKeyJdbcTypeCode"),
+ DotName.createSimple("org.hibernate.annotations.MapKeyMutability"),
DotName.createSimple("org.hibernate.annotations.MapKeyType"),
+ DotName.createSimple("org.hibernate.annotations.Mutability"),
DotName.createSimple("org.hibernate.annotations.NamedNativeQueries"),
DotName.createSimple("org.hibernate.annotations.NamedNativeQuery"),
DotName.createSimple("org.hibernate.annotations.NamedQueries"),
@@ -187,31 +264,41 @@ private HibernateOrmAnnotations() {
DotName.createSimple("org.hibernate.annotations.ParamDef"),
DotName.createSimple("org.hibernate.annotations.Parameter"),
DotName.createSimple("org.hibernate.annotations.Parent"),
+ DotName.createSimple("org.hibernate.annotations.PartitionKey"),
DotName.createSimple("org.hibernate.annotations.Persister"),
DotName.createSimple("org.hibernate.annotations.Polymorphism"),
DotName.createSimple("org.hibernate.annotations.Proxy"),
DotName.createSimple("org.hibernate.annotations.RowId"),
DotName.createSimple("org.hibernate.annotations.SQLDelete"),
DotName.createSimple("org.hibernate.annotations.SQLDeleteAll"),
+ DotName.createSimple("org.hibernate.annotations.SQLDeletes"),
DotName.createSimple("org.hibernate.annotations.SQLInsert"),
+ DotName.createSimple("org.hibernate.annotations.SQLInserts"),
+ DotName.createSimple("org.hibernate.annotations.SQLSelect"),
DotName.createSimple("org.hibernate.annotations.SQLUpdate"),
+ DotName.createSimple("org.hibernate.annotations.SQLUpdates"),
+ DotName.createSimple("org.hibernate.annotations.SecondaryRow"),
+ DotName.createSimple("org.hibernate.annotations.SecondaryRows"),
DotName.createSimple("org.hibernate.annotations.SelectBeforeUpdate"),
- DotName.createSimple("org.hibernate.annotations.Sort"),
DotName.createSimple("org.hibernate.annotations.SortComparator"),
DotName.createSimple("org.hibernate.annotations.SortNatural"),
DotName.createSimple("org.hibernate.annotations.Source"),
DotName.createSimple("org.hibernate.annotations.SqlFragmentAlias"),
+ DotName.createSimple("org.hibernate.annotations.Struct"),
DotName.createSimple("org.hibernate.annotations.Subselect"),
DotName.createSimple("org.hibernate.annotations.Synchronize"),
DotName.createSimple("org.hibernate.annotations.Table"),
DotName.createSimple("org.hibernate.annotations.Tables"),
DotName.createSimple("org.hibernate.annotations.Target"),
- DotName.createSimple("org.hibernate.annotations.Tuplizer"),
- DotName.createSimple("org.hibernate.annotations.Tuplizers"),
+ DotName.createSimple("org.hibernate.annotations.TenantId"),
+ DotName.createSimple("org.hibernate.annotations.TimeZoneColumn"),
+ DotName.createSimple("org.hibernate.annotations.TimeZoneStorage"),
DotName.createSimple("org.hibernate.annotations.Type"),
- DotName.createSimple("org.hibernate.annotations.TypeDef"),
- DotName.createSimple("org.hibernate.annotations.TypeDefs"),
+ DotName.createSimple("org.hibernate.annotations.TypeBinderType"),
+ DotName.createSimple("org.hibernate.annotations.TypeRegistration"),
+ DotName.createSimple("org.hibernate.annotations.TypeRegistrations"),
DotName.createSimple("org.hibernate.annotations.UpdateTimestamp"),
+ DotName.createSimple("org.hibernate.annotations.UuidGenerator"),
DotName.createSimple("org.hibernate.annotations.ValueGenerationType"),
DotName.createSimple("org.hibernate.annotations.Where"),
DotName.createSimple("org.hibernate.annotations.WhereJoinTable"));
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmConfigPersistenceUnit.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmConfigPersistenceUnit.java
index 3f478122b4b1e..f346d4c3b73b0 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmConfigPersistenceUnit.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmConfigPersistenceUnit.java
@@ -10,8 +10,6 @@
import java.util.OptionalLong;
import java.util.Set;
-import org.hibernate.engine.query.spi.QueryPlanCache;
-
import io.quarkus.runtime.annotations.ConfigDocMapKey;
import io.quarkus.runtime.annotations.ConfigDocSection;
import io.quarkus.runtime.annotations.ConfigGroup;
@@ -332,7 +330,7 @@ public enum NullOrdering {
/**
* The maximum size of the query plan cache.
- * see #{@value QueryPlanCache#DEFAULT_QUERY_PLAN_MAX_COUNT}
+ * see #{@value org.hibernate.cfg.AvailableSettings#QUERY_PLAN_CACHE_MAX_SIZE}
*/
@ConfigItem(defaultValue = "2048")
public int queryPlanCacheMaxSize;
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java
index 4e57ee82cb690..5ed792946a02f 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateOrmProcessor.java
@@ -3,7 +3,7 @@
import static io.quarkus.deployment.annotations.ExecutionTime.RUNTIME_INIT;
import static io.quarkus.deployment.annotations.ExecutionTime.STATIC_INIT;
import static io.quarkus.hibernate.orm.deployment.HibernateConfigUtil.firstPresent;
-import static org.hibernate.cfg.AvailableSettings.JPA_SHARED_CACHE_MODE;
+import static org.hibernate.cfg.AvailableSettings.JAKARTA_SHARED_CACHE_MODE;
import static org.hibernate.cfg.AvailableSettings.USE_DIRECT_REFERENCE_CACHE_ENTRIES;
import static org.hibernate.cfg.AvailableSettings.USE_QUERY_CACHE;
import static org.hibernate.cfg.AvailableSettings.USE_SECOND_LEVEL_CACHE;
@@ -29,6 +29,7 @@
import java.util.Properties;
import java.util.Set;
import java.util.TreeSet;
+import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
@@ -45,14 +46,27 @@
import org.hibernate.boot.archive.scan.spi.ClassDescriptor;
import org.hibernate.boot.archive.scan.spi.PackageDescriptor;
+import org.hibernate.boot.beanvalidation.BeanValidationIntegrator;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator;
+import org.hibernate.graph.internal.parse.SubGraphGenerator;
+import org.hibernate.graph.spi.AttributeNodeImplementor;
+import org.hibernate.graph.spi.GraphImplementor;
import org.hibernate.id.SequenceMismatchStrategy;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.jpa.boot.internal.EntityManagerFactoryBuilderImpl;
import org.hibernate.jpa.boot.internal.ParsedPersistenceXmlDescriptor;
import org.hibernate.loader.BatchFetchStyle;
+import org.hibernate.query.hql.spi.DotIdentifierConsumer;
+import org.hibernate.query.hql.spi.SqmCreationProcessingState;
+import org.hibernate.query.sqm.spi.ParameterDeclarationContext;
+import org.hibernate.query.sqm.sql.FromClauseIndex;
+import org.hibernate.sql.ast.Clause;
+import org.hibernate.sql.ast.spi.SqlAstProcessingState;
+import org.hibernate.sql.ast.tree.Statement;
+import org.hibernate.sql.ast.tree.select.QueryPart;
+import org.hibernate.sql.results.graph.FetchParent;
+import org.hibernate.sql.results.jdbc.spi.JdbcValuesSourceProcessingState;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget.Kind;
import org.jboss.jandex.AnnotationValue;
@@ -301,22 +315,12 @@ AdditionalIndexedClassesBuildItem addPersistenceUnitAnnotationToIndex() {
return new AdditionalIndexedClassesBuildItem(ClassNames.QUARKUS_PERSISTENCE_UNIT.toString());
}
- // We do our own enhancement during the compilation phase, so disable any
- // automatic entity enhancement by Hibernate ORM
- // This has to happen before Hibernate ORM classes are initialized: see
- // org.hibernate.cfg.Environment#BYTECODE_PROVIDER_INSTANCE
- @BuildStep
- public SystemPropertyBuildItem enforceDisableRuntimeEnhancer() {
- return new SystemPropertyBuildItem(AvailableSettings.BYTECODE_PROVIDER,
- org.hibernate.cfg.Environment.BYTECODE_PROVIDER_NAME_NONE);
- }
-
@BuildStep
public void enrollBeanValidationTypeSafeActivatorForReflection(Capabilities capabilities,
BuildProducer reflectiveClasses) {
if (capabilities.isPresent(Capability.HIBERNATE_VALIDATOR)) {
reflectiveClasses.produce(new ReflectiveClassBuildItem(true, true,
- "org.hibernate.cfg.beanvalidation.TypeSafeActivator"));
+ "org.hibernate.boot.beanvalidation.TypeSafeActivator"));
reflectiveClasses.produce(new ReflectiveClassBuildItem(false, false, false,
BeanValidationIntegrator.BV_CHECK_CLASS));
}
@@ -799,7 +803,7 @@ public void multitenancy(HibernateOrmRecorder recorder,
public void produceLoggingCategories(HibernateOrmConfig hibernateOrmConfig,
BuildProducer categories) {
if (hibernateOrmConfig.log.bindParam || hibernateOrmConfig.log.bindParameters) {
- categories.produce(new LogCategoryBuildItem("org.hibernate.type.descriptor.sql.BasicBinder", Level.TRACE, true));
+ categories.produce(new LogCategoryBuildItem("org.hibernate.orm.jdbc.bind", Level.TRACE, true));
}
}
@@ -977,7 +981,7 @@ private static void producePersistenceUnitDescriptorFromConfig(
// The datasource is optional for the DATABASE multi-tenancy strategy,
// since the datasource will be resolved separately for each tenant.
if (explicitDialect.isPresent()) {
- dialect = explicitDialect.get();
+ dialect = explicitDialectSet(explicitDialect.get());
} else if (jdbcDataSource.isPresent()) {
dialect = Dialects.guessDialect(persistenceUnitName, jdbcDataSource.get().getDbKind(),
dbKindMetadataBuildItems);
@@ -1001,7 +1005,7 @@ private static void producePersistenceUnitDescriptorFromConfig(
"quarkus.datasource.password", "quarkus.datasource.jdbc.url")));
}
if (explicitDialect.isPresent()) {
- dialect = explicitDialect.get();
+ dialect = explicitDialectSet(explicitDialect.get());
} else {
dialect = Dialects.guessDialect(persistenceUnitName, jdbcDataSource.get().getDbKind(),
dbKindMetadataBuildItems);
@@ -1167,7 +1171,7 @@ private static void producePersistenceUnitDescriptorFromConfig(
p.putIfAbsent(USE_DIRECT_REFERENCE_CACHE_ENTRIES, Boolean.TRUE);
p.putIfAbsent(USE_SECOND_LEVEL_CACHE, Boolean.TRUE);
p.putIfAbsent(USE_QUERY_CACHE, Boolean.TRUE);
- p.putIfAbsent(JPA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE);
+ p.putIfAbsent(JAKARTA_SHARED_CACHE_MODE, SharedCacheMode.ENABLE_SELECTIVE);
Map cacheConfigEntries = HibernateConfigUtil.getCacheConfigEntries(persistenceUnitConfig);
for (Entry entry : cacheConfigEntries.entrySet()) {
descriptor.getProperties().setProperty(entry.getKey(), entry.getValue());
@@ -1178,16 +1182,17 @@ private static void producePersistenceUnitDescriptorFromConfig(
p.put(USE_DIRECT_REFERENCE_CACHE_ENTRIES, Boolean.FALSE);
p.put(USE_SECOND_LEVEL_CACHE, Boolean.FALSE);
p.put(USE_QUERY_CACHE, Boolean.FALSE);
- p.put(JPA_SHARED_CACHE_MODE, SharedCacheMode.NONE);
+ p.put(JAKARTA_SHARED_CACHE_MODE, SharedCacheMode.NONE);
}
// Hibernate Validator integration: we force the callback mode to have bootstrap errors reported rather than validation ignored
// if there is any issue when bootstrapping Hibernate Validator.
if (capabilities.isPresent(Capability.HIBERNATE_VALIDATOR)) {
if (persistenceUnitConfig.validation.enabled) {
- descriptor.getProperties().setProperty(AvailableSettings.JPA_VALIDATION_MODE, ValidationMode.CALLBACK.name());
+ descriptor.getProperties().setProperty(AvailableSettings.JAKARTA_VALIDATION_MODE,
+ ValidationMode.CALLBACK.name());
} else {
- descriptor.getProperties().setProperty(AvailableSettings.JPA_VALIDATION_MODE, ValidationMode.NONE.name());
+ descriptor.getProperties().setProperty(AvailableSettings.JAKARTA_VALIDATION_MODE, ValidationMode.NONE.name());
}
}
@@ -1210,6 +1215,15 @@ private static void producePersistenceUnitDescriptorFromConfig(
false, false));
}
+ private static String explicitDialectSet(String configuredDialectName) {
+ if ("org.hibernate.dialect.H2Dialect".equals(configuredDialectName)) {
+ LOG.warn(
+ "The dialect property of Hibernate ORM was explicitly set to 'org.hibernate.dialect.H2Dialect'; this won't work in Quarkus - overriding to 'io.quarkus.hibernate.orm.runtime.dialect.QuarkusH2Dialect'.");
+ return "io.quarkus.hibernate.orm.runtime.dialect.QuarkusH2Dialect";
+ }
+ return configuredDialectName;
+ }
+
private static Optional findJdbcDataSource(String persistenceUnitName,
HibernateOrmConfigPersistenceUnit persistenceUnitConfig, List jdbcDataSources) {
if (persistenceUnitConfig.datasource.isPresent()) {
@@ -1598,6 +1612,30 @@ private TypePool createTransformedClassesTypePool(TransformedClassesBuildItem tr
ClassFileLocator.ForClassLoader.of(Thread.currentThread().getContextClassLoader())));
}
+ //TODO cleanup: this should be unneccessary but we generate them to not having to wait for Hibernate ORM 6.2.0.Final,
+ //which is expected to contain the same metadata.
+ @BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
+ public ReflectiveClassBuildItem additionalStaticReflectionNeeds() {
+ return new ReflectiveClassBuildItem(true, false, false,
+ AttributeNodeImplementor[].class,
+ Clause[].class,
+ DotIdentifierConsumer[].class,
+ FetchParent[].class,
+ FromClauseIndex[].class,
+ Function[].class,
+ GraphImplementor[].class,
+ JdbcValuesSourceProcessingState[].class,
+ List[].class,
+ Entry[].class,
+ ParameterDeclarationContext[].class,
+ QueryPart[].class,
+ SqlAstProcessingState[].class,
+ SqmCreationProcessingState[].class,
+ Statement[].class,
+ SubGraphGenerator[].class,
+ Supplier[].class);
+ }
+
private boolean isModified(String entity, Set changedClasses, IndexView index) {
if (changedClasses.contains(entity)) {
return true;
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateUserTypeProcessor.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateUserTypeProcessor.java
index edf031dcd0dde..8e7adb55a5d99 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateUserTypeProcessor.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/HibernateUserTypeProcessor.java
@@ -1,6 +1,5 @@
package io.quarkus.hibernate.orm.deployment;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@@ -28,20 +27,6 @@ public void build(BuildProducer reflectiveClass, Combi
final Set userTypes = new HashSet<>();
Collection typeAnnotationInstances = index.getAnnotations(ClassNames.TYPE);
- Collection typeDefinitionAnnotationInstances = index.getAnnotations(ClassNames.TYPE_DEFINITION);
- Collection typeDefinitionsAnnotationInstances = index.getAnnotations(ClassNames.TYPE_DEFINITIONS);
-
- userTypes.addAll(getUserTypes(typeDefinitionAnnotationInstances));
-
- for (AnnotationInstance typeDefinitionAnnotationInstance : typeDefinitionsAnnotationInstances) {
- final AnnotationValue typeDefinitionsAnnotationValue = typeDefinitionAnnotationInstance.value();
-
- if (typeDefinitionsAnnotationValue == null) {
- continue;
- }
-
- userTypes.addAll(getUserTypes(Arrays.asList(typeDefinitionsAnnotationValue.asNestedArray())));
- }
for (AnnotationInstance typeAnnotationInstance : typeAnnotationInstances) {
final AnnotationValue typeValue = typeAnnotationInstance.value(TYPE_VALUE);
diff --git a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/JpaJandexScavenger.java b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/JpaJandexScavenger.java
index 1d48665ff8724..21030f72f042f 100644
--- a/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/JpaJandexScavenger.java
+++ b/extensions/hibernate-orm/deployment/src/main/java/io/quarkus/hibernate/orm/deployment/JpaJandexScavenger.java
@@ -19,17 +19,17 @@
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmJoinedSubclassEntityType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmRootEntityType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmUnionSubclassEntityType;
-import org.hibernate.boot.jaxb.mapping.spi.EntityOrMappedSuperclass;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbConverter;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEmbeddable;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEntity;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListener;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityListeners;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbMappedSuperclass;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitDefaults;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbPersistenceUnitMetadata;
-import org.hibernate.boot.jaxb.mapping.spi.ManagedType;
+import org.hibernate.boot.jaxb.mapping.EntityOrMappedSuperclass;
+import org.hibernate.boot.jaxb.mapping.JaxbConverter;
+import org.hibernate.boot.jaxb.mapping.JaxbEmbeddable;
+import org.hibernate.boot.jaxb.mapping.JaxbEntity;
+import org.hibernate.boot.jaxb.mapping.JaxbEntityListener;
+import org.hibernate.boot.jaxb.mapping.JaxbEntityListeners;
+import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
+import org.hibernate.boot.jaxb.mapping.JaxbMappedSuperclass;
+import org.hibernate.boot.jaxb.mapping.JaxbPersistenceUnitDefaults;
+import org.hibernate.boot.jaxb.mapping.JaxbPersistenceUnitMetadata;
+import org.hibernate.boot.jaxb.mapping.ManagedType;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.ClassInfo;
@@ -90,6 +90,7 @@ public JpaModelBuildItem discoverModelAndRegisterForReflection() {
enlistJPAModelClasses(collector, ClassNames.JPA_ENTITY);
enlistJPAModelClasses(collector, ClassNames.EMBEDDABLE);
enlistJPAModelClasses(collector, ClassNames.MAPPED_SUPERCLASS);
+ enlistJPAModelIdClasses(collector, ClassNames.ID_CLASS);
enlistEmbeddedsAndElementCollections(collector);
enlistPotentialCdiBeanClasses(collector, ClassNames.CONVERTER);
@@ -198,17 +199,17 @@ private void enlistOrmXmlMapping(Collector collector, JaxbEntityMappings mapping
enlistOrmXmlMappingListeners(collector, packagePrefix, defaults.getEntityListeners());
}
- for (JaxbEntity entity : mapping.getEntity()) {
+ for (JaxbEntity entity : mapping.getEntities()) {
enlistOrmXmlMappingManagedClass(collector, packagePrefix, entity, "entity");
}
- for (JaxbMappedSuperclass mappedSuperclass : mapping.getMappedSuperclass()) {
+ for (JaxbMappedSuperclass mappedSuperclass : mapping.getMappedSuperclasses()) {
enlistOrmXmlMappingManagedClass(collector, packagePrefix, mappedSuperclass, "mapped-superclass");
}
- for (JaxbEmbeddable embeddable : mapping.getEmbeddable()) {
+ for (JaxbEmbeddable embeddable : mapping.getEmbeddables()) {
String name = safeGetClassName(packagePrefix, embeddable, "embeddable");
enlistExplicitClass(collector, name);
}
- for (JaxbConverter converter : mapping.getConverter()) {
+ for (JaxbConverter converter : mapping.getConverters()) {
collector.potentialCdiBeanTypes.add(DotName.createSimple(qualifyIfNecessary(packagePrefix, converter.getClazz())));
}
}
@@ -375,6 +376,20 @@ private void enlistJPAModelClasses(Collector collector, DotName dotName) {
}
}
+ private void enlistJPAModelIdClasses(Collector collector, DotName dotName) {
+ Collection jpaAnnotations = index.getAnnotations(dotName);
+
+ if (jpaAnnotations == null) {
+ return;
+ }
+
+ for (AnnotationInstance annotation : jpaAnnotations) {
+ DotName targetDotName = annotation.value().asClass().name();
+ addClassHierarchyToReflectiveList(collector, targetDotName);
+ collector.modelTypes.add(targetDotName.toString());
+ }
+ }
+
private void enlistPotentialCdiBeanClasses(Collector collector, DotName dotName) {
Collection jpaAnnotations = index.getAnnotations(dotName);
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateOrmAnnotationsTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateOrmAnnotationsTest.java
index d9e356bc3edc9..03a1fa4e4acc0 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateOrmAnnotationsTest.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/HibernateOrmAnnotationsTest.java
@@ -74,16 +74,24 @@ public void testNoMissingHibernateAnnotation() {
Set hibernateMappingAnnotations = findRuntimeAnnotations(hibernateIndex);
hibernateMappingAnnotations.removeIf(name -> name.toString().contains(".internal."));
hibernateMappingAnnotations.removeIf(name -> name.toString().contains(".spi."));
+ ignoreInternalAnnotations(hibernateMappingAnnotations);
assertThat(HibernateOrmAnnotations.HIBERNATE_MAPPING_ANNOTATIONS)
.containsExactlyInAnyOrderElementsOf(hibernateMappingAnnotations);
}
+ private static void ignoreInternalAnnotations(Set annotationSet) {
+ annotationSet.removeIf(name -> name.toString().equals("org.hibernate.Incubating"));
+ annotationSet.removeIf(name -> name.toString().equals("org.hibernate.Internal"));
+ annotationSet.removeIf(name -> name.toString().equals("org.hibernate.Remove"));
+ }
+
@Test
public void testNoMissingPackageLevelAnnotation() {
Set packageLevelHibernateAnnotations = findRuntimeAnnotationsByTargetType(jpaIndex, ElementType.PACKAGE);
packageLevelHibernateAnnotations.addAll(findRuntimeAnnotationsByTargetType(hibernateIndex, ElementType.PACKAGE));
packageLevelHibernateAnnotations.removeIf(name -> name.toString().contains(".internal."));
+ ignoreInternalAnnotations(packageLevelHibernateAnnotations);
assertThat(HibernateOrmAnnotations.PACKAGE_ANNOTATIONS)
.containsExactlyInAnyOrderElementsOf(packageLevelHibernateAnnotations);
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/DevConsoleInfoSupplierTestResource.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/DevConsoleInfoSupplierTestResource.java
index cb49eafd682bd..ea8cd0d554854 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/DevConsoleInfoSupplierTestResource.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/DevConsoleInfoSupplierTestResource.java
@@ -83,14 +83,14 @@ public String checkPuInfoWithFailingDDLGeneration() {
.returns(MyEntityWithFailingDDLGeneration.TABLE_NAME,
HibernateOrmDevConsoleInfoSupplier.EntityInfo::getTableName);
- // But some DDL scripts are replaced with whatever exception occurred
assertThat(pu.getCreateDDL())
- .contains("Could not generate DDL")
- .contains("org.hibernate.MappingException: No Dialect mapping for JDBC type: "
- + TypeWithUnsupportedSqlCode.UNSUPPORTED_SQL_CODE);
+ .contains("Error creating SQL create commands for table : MyEntityTable")
+ .contains("org.hibernate.HibernateException: No type mapping for org.hibernate.type.SqlTypes code: "
+ + TypeWithUnsupportedSqlCode.UNSUPPORTED_SQL_CODE + " (UNKNOWN("
+ + TypeWithUnsupportedSqlCode.UNSUPPORTED_SQL_CODE + "))");
// Drop script generation doesn't involve column types, so it didn't fail
assertThat(pu.getDropDDL())
- .contains("drop table if exists MyEntityTable");
+ .contains("drop table MyEntityTable if exists");
return "OK";
}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/DevConsolePuInformationFailingDDLGenerationTestCase.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/DevConsolePuInformationFailingDDLGenerationTestCase.java
index 6e5ec71a4b02e..7bfb2b301a574 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/DevConsolePuInformationFailingDDLGenerationTestCase.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/DevConsolePuInformationFailingDDLGenerationTestCase.java
@@ -14,8 +14,9 @@ public class DevConsolePuInformationFailingDDLGenerationTestCase {
.withApplicationRoot((jar) -> jar
.addClasses(MyEntityWithFailingDDLGeneration.class,
TypeWithUnsupportedSqlCode.class,
+ H2CustomDialect.class,
DevConsoleInfoSupplierTestResource.class)
- .addAsResource("application-generation-none.properties", "application.properties")
+ .addAsResource("application-generation-none-customh2.properties", "application.properties")
.addAsResource("import-custom-table-name.sql", "import.sql"));
@Test
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/H2CustomDialect.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/H2CustomDialect.java
new file mode 100644
index 0000000000000..21c96ead9e605
--- /dev/null
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/H2CustomDialect.java
@@ -0,0 +1,53 @@
+package io.quarkus.hibernate.orm.devconsole;
+
+import org.hibernate.dialect.H2Dialect;
+import org.hibernate.metamodel.mapping.EntityMappingType;
+import org.hibernate.metamodel.spi.RuntimeModelCreationContext;
+import org.hibernate.query.spi.DomainQueryExecutionContext;
+import org.hibernate.query.sqm.internal.DomainParameterXref;
+import org.hibernate.query.sqm.mutation.spi.SqmMultiTableInsertStrategy;
+import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
+import org.hibernate.query.sqm.tree.delete.SqmDeleteStatement;
+import org.hibernate.query.sqm.tree.insert.SqmInsertStatement;
+import org.hibernate.query.sqm.tree.update.SqmUpdateStatement;
+
+public class H2CustomDialect extends H2Dialect {
+
+ @Override
+ public SqmMultiTableMutationStrategy getFallbackSqmMutationStrategy(
+ EntityMappingType entityDescriptor,
+ RuntimeModelCreationContext runtimeModelCreationContext) {
+ return new SqmMultiTableMutationStrategy() {
+ @Override
+ public int executeUpdate(
+ SqmUpdateStatement> sqmUpdateStatement,
+ DomainParameterXref domainParameterXref,
+ DomainQueryExecutionContext domainQueryExecutionContext) {
+ return 0;
+ }
+
+ @Override
+ public int executeDelete(
+ SqmDeleteStatement> sqmDeleteStatement,
+ DomainParameterXref domainParameterXref,
+ DomainQueryExecutionContext domainQueryExecutionContext) {
+ return 0;
+ }
+ };
+ }
+
+ @Override
+ public SqmMultiTableInsertStrategy getFallbackSqmInsertStrategy(
+ EntityMappingType entityDescriptor,
+ RuntimeModelCreationContext runtimeModelCreationContext) {
+ return new SqmMultiTableInsertStrategy() {
+ @Override
+ public int executeInsert(
+ SqmInsertStatement> sqmInsertStatement,
+ DomainParameterXref domainParameterXref,
+ DomainQueryExecutionContext domainQueryExecutionContext) {
+ return 0;
+ }
+ };
+ }
+}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/MyEntityWithFailingDDLGeneration.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/MyEntityWithFailingDDLGeneration.java
index aaaa30ecec2de..56e89c8723be8 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/MyEntityWithFailingDDLGeneration.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/MyEntityWithFailingDDLGeneration.java
@@ -7,11 +7,9 @@
import jakarta.persistence.Table;
import org.hibernate.annotations.Type;
-import org.hibernate.annotations.TypeDef;
@Entity(name = MyEntityWithFailingDDLGeneration.NAME)
@Table(name = MyEntityWithFailingDDLGeneration.TABLE_NAME)
-@TypeDef(name = "typeWithUnsupportedSqlCode", typeClass = TypeWithUnsupportedSqlCode.class)
public class MyEntityWithFailingDDLGeneration {
public static final String NAME = "MyEntity";
public static final String TABLE_NAME = "MyEntityTable";
@@ -21,7 +19,7 @@ public class MyEntityWithFailingDDLGeneration {
public Long id;
// The goal of this custom type is to trigger an error during DDL generation
- @Type(type = "typeWithUnsupportedSqlCode")
+ @Type(TypeWithUnsupportedSqlCode.class)
public String name;
public MyEntityWithFailingDDLGeneration() {
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/TypeWithUnsupportedSqlCode.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/TypeWithUnsupportedSqlCode.java
index 8d1f7bc74a7f0..e8ccc3296ed65 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/TypeWithUnsupportedSqlCode.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/devconsole/TypeWithUnsupportedSqlCode.java
@@ -3,32 +3,24 @@
import java.io.Serializable;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Types;
import java.util.Objects;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.usertype.UserType;
-public class TypeWithUnsupportedSqlCode implements UserType {
+public class TypeWithUnsupportedSqlCode implements UserType {
- public static final int UNSUPPORTED_SQL_CODE = Types.ARRAY;
+ public static final int UNSUPPORTED_SQL_CODE = Integer.MAX_VALUE;
@Override
- public int[] sqlTypes() {
- return new int[] { UNSUPPORTED_SQL_CODE };
- }
-
- @Override
- public Object nullSafeGet(ResultSet result, String[] names, SharedSessionContractImplementor session, Object owner)
- throws SQLException {
+ public void nullSafeSet(PreparedStatement preparedStatement, String value, int index,
+ SharedSessionContractImplementor session) {
throw new UnsupportedOperationException("Should not be called - this type is not used at runtime");
}
@Override
- public void nullSafeSet(PreparedStatement preparedStatement, Object value, int index,
- SharedSessionContractImplementor session) throws SQLException {
- throw new UnsupportedOperationException("Should not be called - this type is not used at runtime");
+ public int getSqlType() {
+ return UNSUPPORTED_SQL_CODE;
}
@Override
@@ -37,17 +29,23 @@ public Class returnedClass() {
}
@Override
- public boolean equals(Object o, Object o1) {
+ public boolean equals(String o, String o1) {
return Objects.equals(o, o1);
}
@Override
- public int hashCode(Object o) {
+ public int hashCode(String o) {
return o.hashCode();
}
@Override
- public Object deepCopy(Object o) {
+ public String nullSafeGet(ResultSet resultSet, int i, SharedSessionContractImplementor sharedSessionContractImplementor,
+ Object o) {
+ throw new UnsupportedOperationException("Should not be called - this type is not used at runtime");
+ }
+
+ @Override
+ public String deepCopy(String o) {
return o;
}
@@ -57,17 +55,17 @@ public boolean isMutable() {
}
@Override
- public Serializable disassemble(Object o) {
+ public Serializable disassemble(String o) {
return (Serializable) o;
}
@Override
- public Object assemble(Serializable cached, Object o) {
- return cached;
+ public String assemble(Serializable cached, Object o) {
+ return (String) cached;
}
@Override
- public Object replace(Object o, Object t, Object owner) {
+ public String replace(String o, String t, Object owner) {
return o;
}
}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/metadatabuildercontributor/CustomMetadataBuilderContributor.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/metadatabuildercontributor/CustomMetadataBuilderContributor.java
index 5f05078a75743..5f72d49cc8daf 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/metadatabuildercontributor/CustomMetadataBuilderContributor.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/metadatabuildercontributor/CustomMetadataBuilderContributor.java
@@ -1,49 +1,58 @@
package io.quarkus.hibernate.orm.metadatabuildercontributor;
+import static org.hibernate.query.sqm.produce.function.FunctionParameterType.STRING;
+
import java.util.List;
-import org.hibernate.QueryException;
import org.hibernate.boot.MetadataBuilder;
-import org.hibernate.boot.spi.MetadataBuilderContributor;
-import org.hibernate.dialect.function.SQLFunction;
-import org.hibernate.engine.spi.Mapping;
-import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.type.StringType;
-import org.hibernate.type.Type;
-
-public class CustomMetadataBuilderContributor implements MetadataBuilderContributor {
+import org.hibernate.boot.model.FunctionContributions;
+import org.hibernate.boot.model.FunctionContributor;
+import org.hibernate.query.sqm.function.AbstractSqmSelfRenderingFunctionDescriptor;
+import org.hibernate.query.sqm.produce.function.StandardArgumentsValidators;
+import org.hibernate.query.sqm.produce.function.StandardFunctionArgumentTypeResolvers;
+import org.hibernate.query.sqm.produce.function.StandardFunctionReturnTypeResolvers;
+import org.hibernate.sql.ast.SqlAstNodeRenderingMode;
+import org.hibernate.sql.ast.SqlAstTranslator;
+import org.hibernate.sql.ast.spi.SqlAppender;
+import org.hibernate.sql.ast.tree.SqlAstNode;
+import org.hibernate.type.StandardBasicTypes;
+import org.hibernate.type.spi.TypeConfiguration;
+
+public class CustomMetadataBuilderContributor implements org.hibernate.boot.spi.MetadataBuilderContributor,
+ FunctionContributor {
+
@Override
public void contribute(MetadataBuilder metadataBuilder) {
- metadataBuilder.applySqlFunction(
+ metadataBuilder.applyFunctions(this);
+ }
+
+ @Override
+ public void contributeFunctions(FunctionContributions functionContributions) {
+ TypeConfiguration typeConfiguration = functionContributions.getTypeConfiguration();
+ functionContributions.getFunctionRegistry().register(
"addHardcodedSuffix",
- new HardcodedSuffixFunction("_some_suffix"));
+ new HardcodedSuffixFunction(typeConfiguration, "_some_suffix"));
}
- private static final class HardcodedSuffixFunction implements SQLFunction {
+ private static final class HardcodedSuffixFunction extends AbstractSqmSelfRenderingFunctionDescriptor
+ implements org.hibernate.query.sqm.function.SqmFunctionDescriptor {
private final String suffix;
- private HardcodedSuffixFunction(String suffix) {
+ private HardcodedSuffixFunction(TypeConfiguration typeConfiguration, String suffix) {
+ super(
+ "constantSuffix",
+ StandardArgumentsValidators.exactly(1),
+ StandardFunctionReturnTypeResolvers.invariant(
+ typeConfiguration.getBasicTypeRegistry().resolve(StandardBasicTypes.STRING)),
+ StandardFunctionArgumentTypeResolvers.impliedOrInvariant(typeConfiguration, STRING));
this.suffix = suffix;
}
@Override
- public boolean hasArguments() {
- return true;
- }
-
- @Override
- public boolean hasParenthesesIfNoArguments() {
- return false;
- }
-
- @Override
- public Type getReturnType(Type firstArgumentType, Mapping mapping) throws QueryException {
- return StringType.INSTANCE;
- }
-
- @Override
- public String render(Type firstArgumentType, List arguments, SessionFactoryImplementor factory) throws QueryException {
- return "(" + arguments.get(0) + " || '" + suffix + "')";
+ public void render(SqlAppender sqlAppender, List extends SqlAstNode> sqlAstArguments, SqlAstTranslator> walker) {
+ sqlAppender.appendSql('(');
+ walker.render(sqlAstArguments.get(0), SqlAstNodeRenderingMode.DEFAULT);
+ sqlAppender.appendSql(" || '" + suffix + "')");
}
}
}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsCdiEntityManagerTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsCdiEntityManagerTest.java
index 3866961095489..11b4de766f97c 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsCdiEntityManagerTest.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsCdiEntityManagerTest.java
@@ -151,6 +151,6 @@ public void inventoryEntityManagerNoRequestNoTransaction() {
public void testUserInInventoryEntityManager() {
User user = new User("gsmet");
assertThatThrownBy(() -> inventoryEntityManager.persist(user)).isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("Unknown entity");
+ .hasMessageContaining("Unable to locate persister");
}
}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsCdiSessionTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsCdiSessionTest.java
index e4b616c6452f0..60f87c1c63aba 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsCdiSessionTest.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsCdiSessionTest.java
@@ -151,6 +151,6 @@ public void inventoryEntityManagerNoRequestNoTransaction() {
public void testUserInInventorySession() {
User user = new User("gsmet");
assertThatThrownBy(() -> inventorySession.persist(user)).isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("Unknown entity");
+ .hasMessageContaining("Unable to locate persister");
}
}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsPackageAnnotationsTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsPackageAnnotationsTest.java
index 01640faa96d20..86265c074ecc7 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsPackageAnnotationsTest.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsPackageAnnotationsTest.java
@@ -93,6 +93,6 @@ public void testPlane() {
public void testUserInInventoryEntityManager() {
User user = new User("gsmet");
assertThatThrownBy(() -> inventoryEntityManager.persist(user)).isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("Unknown entity");
+ .hasMessageContaining("Unable to locate persister");
}
}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsResourceInjectionEntityManagerTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsResourceInjectionEntityManagerTest.java
index de7eb15cbae28..d115d67dfb842 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsResourceInjectionEntityManagerTest.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsResourceInjectionEntityManagerTest.java
@@ -54,7 +54,7 @@ public void testPlane() {
public void testUserInInventoryEntityManager() {
User user = new User("gsmet");
assertThatThrownBy(() -> inventoryEntityManager.persist(user)).isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("Unknown entity");
+ .hasMessageContaining("Unable to locate persister");
}
@Test
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsResourceInjectionSessionTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsResourceInjectionSessionTest.java
index 1296ef7636856..b13741e7a9490 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsResourceInjectionSessionTest.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/multiplepersistenceunits/MultiplePersistenceUnitsResourceInjectionSessionTest.java
@@ -54,7 +54,7 @@ public void testPlane() {
public void testUserInInventorySession() {
User user = new User("gsmet");
assertThatThrownBy(() -> inventorySession.persist(user)).isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("Unknown entity");
+ .hasMessageContaining("Unable to locate persister");
}
@Test
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/ChildEntity1.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/ChildEntity1.java
deleted file mode 100644
index fa9bca678edb7..0000000000000
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/ChildEntity1.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package io.quarkus.hibernate.orm.packages;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
-
-@Entity
-public class ChildEntity1 {
-
- @Id
- @GeneratedValue
- private long id;
-
- private String name;
-
- public ChildEntity1() {
- }
-
- @Override
- public String toString() {
- return "ChildEntity1:" + name;
- }
-
- public ChildEntity1(String name) {
- this.name = name;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/ChildEntity2.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/ChildEntity2.java
deleted file mode 100644
index 2feed342d0f86..0000000000000
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/ChildEntity2.java
+++ /dev/null
@@ -1,43 +0,0 @@
-package io.quarkus.hibernate.orm.packages;
-
-import jakarta.persistence.Entity;
-import jakarta.persistence.GeneratedValue;
-import jakarta.persistence.Id;
-
-@Entity
-public class ChildEntity2 {
-
- @Id
- @GeneratedValue
- private long id;
-
- private String name;
-
- public ChildEntity2() {
- }
-
- @Override
- public String toString() {
- return "ChildEntity1:" + name;
- }
-
- public ChildEntity2(String name) {
- this.name = name;
- }
-
- public long getId() {
- return id;
- }
-
- public void setId(long id) {
- this.id = id;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/PackageLevelAnnotationTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/PackageLevelAnnotationTest.java
index 55f4335c0baa9..204fb5ac8e796 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/PackageLevelAnnotationTest.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/PackageLevelAnnotationTest.java
@@ -2,6 +2,8 @@
import static org.assertj.core.api.Assertions.assertThat;
+import java.util.List;
+
import jakarta.inject.Inject;
import jakarta.persistence.EntityManager;
import jakarta.transaction.UserTransaction;
@@ -29,29 +31,16 @@ public class PackageLevelAnnotationTest {
@Test
public void test() {
- // If we get here, the package-level @AnyMetaDef was correctly detected:
- // otherwise, we would have had a failure on ORM bootstrap.
-
ParentEntity parent1 = new ParentEntity("parent1");
- ParentEntity parent2 = new ParentEntity("parent2");
- ChildEntity1 child1 = new ChildEntity1("child1");
- ChildEntity2 child2 = new ChildEntity2("child2");
- parent1.setChild(child1);
- parent2.setChild(child2);
inTransaction(() -> {
- entityManager.persist(child1);
- entityManager.persist(child2);
entityManager.persist(parent1);
- entityManager.persist(parent2);
});
- // Check that the @Any relation works correctly, just in case
inTransaction(() -> {
- ParentEntity savedParent1 = entityManager.find(ParentEntity.class, parent1.getId());
- assertThat(savedParent1.getChild()).isInstanceOf(ChildEntity1.class);
- ParentEntity savedParent2 = entityManager.find(ParentEntity.class, parent2.getId());
- assertThat(savedParent2.getChild()).isInstanceOf(ChildEntity2.class);
+ final List list = entityManager.createNamedQuery("test", ParentEntity.class)
+ .getResultList();
+ assertThat(list.size()).isEqualTo(1);
});
}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/ParentEntity.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/ParentEntity.java
index f58eb8653d7f1..a759a40a3b9f6 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/ParentEntity.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/ParentEntity.java
@@ -1,12 +1,8 @@
package io.quarkus.hibernate.orm.packages;
-import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
-import jakarta.persistence.JoinColumn;
-
-import org.hibernate.annotations.Any;
@Entity
public class ParentEntity {
@@ -17,10 +13,6 @@ public class ParentEntity {
private String name;
- @Any(metaDef = "childrenAnyMetaDef", metaColumn = @Column(name = "child_type"))
- @JoinColumn(name = "child_id")
- private Object child;
-
public ParentEntity() {
}
@@ -48,12 +40,4 @@ public String getName() {
public void setName(String name) {
this.name = name;
}
-
- public Object getChild() {
- return child;
- }
-
- public void setChild(Object child) {
- this.child = child;
- }
}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/package-info.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/package-info.java
index 419886f36205b..9c4d582d3b296 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/package-info.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/packages/package-info.java
@@ -1,8 +1,4 @@
-@AnyMetaDef(name = "childrenAnyMetaDef", idType = "long", metaType = "string", metaValues = {
- @MetaValue(targetEntity = ChildEntity1.class, value = "child1"),
- @MetaValue(targetEntity = ChildEntity2.class, value = "child2")
-})
+@NamedQuery(name = "test", query = "from ParentEntity")
package io.quarkus.hibernate.orm.packages;
-import org.hibernate.annotations.AnyMetaDef;
-import org.hibernate.annotations.MetaValue;
\ No newline at end of file
+import org.hibernate.annotations.NamedQuery;
\ No newline at end of file
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/singlepersistenceunit/SinglePersistenceUnitPackageAnnotationTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/singlepersistenceunit/SinglePersistenceUnitPackageAnnotationTest.java
index 5c68053bc63bb..06f625ec80d8a 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/singlepersistenceunit/SinglePersistenceUnitPackageAnnotationTest.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/singlepersistenceunit/SinglePersistenceUnitPackageAnnotationTest.java
@@ -61,6 +61,6 @@ public void testIncluded() {
public void testExcluded() {
ExcludedEntity entity = new ExcludedEntity("gsmet");
assertThatThrownBy(() -> entityManager.persist(entity)).isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("Unknown entity");
+ .hasMessageContaining("Unable to locate persister");
}
}
diff --git a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/singlepersistenceunit/SinglePersistenceUnitPackageConfigurationTest.java b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/singlepersistenceunit/SinglePersistenceUnitPackageConfigurationTest.java
index 1e9c30a5a1158..fd7eb0ea4277e 100644
--- a/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/singlepersistenceunit/SinglePersistenceUnitPackageConfigurationTest.java
+++ b/extensions/hibernate-orm/deployment/src/test/java/io/quarkus/hibernate/orm/singlepersistenceunit/SinglePersistenceUnitPackageConfigurationTest.java
@@ -62,6 +62,6 @@ public void testIncluded() {
public void testExcluded() {
ExcludedEntity entity = new ExcludedEntity("gsmet");
assertThatThrownBy(() -> entityManager.persist(entity)).isInstanceOf(IllegalArgumentException.class)
- .hasMessageContaining("Unknown entity");
+ .hasMessageContaining("Unable to locate persister");
}
}
diff --git a/extensions/hibernate-orm/deployment/src/test/resources/application-generation-none-customh2.properties b/extensions/hibernate-orm/deployment/src/test/resources/application-generation-none-customh2.properties
new file mode 100644
index 0000000000000..291c12d702c53
--- /dev/null
+++ b/extensions/hibernate-orm/deployment/src/test/resources/application-generation-none-customh2.properties
@@ -0,0 +1,7 @@
+quarkus.datasource.db-kind=h2
+quarkus.datasource.jdbc.url=jdbc:h2:mem:test
+
+#quarkus.hibernate-orm.log.sql=true
+quarkus.hibernate-orm.database.generation=none
+#We need the custom dialect to force the failure to happen exclusively during DDL generation
+quarkus.hibernate-orm.dialect=io.quarkus.hibernate.orm.devconsole.H2CustomDialect
\ No newline at end of file
diff --git a/extensions/hibernate-orm/deployment/src/test/resources/application-generation-none.properties b/extensions/hibernate-orm/deployment/src/test/resources/application-generation-none.properties
deleted file mode 100644
index f6558adf46216..0000000000000
--- a/extensions/hibernate-orm/deployment/src/test/resources/application-generation-none.properties
+++ /dev/null
@@ -1,5 +0,0 @@
-quarkus.datasource.db-kind=h2
-quarkus.datasource.jdbc.url=jdbc:h2:mem:test
-
-#quarkus.hibernate-orm.log.sql=true
-quarkus.hibernate-orm.database.generation=none
diff --git a/extensions/hibernate-orm/runtime/pom.xml b/extensions/hibernate-orm/runtime/pom.xml
index eefcb15c5c1da..cf98b3cd2f12a 100644
--- a/extensions/hibernate-orm/runtime/pom.xml
+++ b/extensions/hibernate-orm/runtime/pom.xml
@@ -57,8 +57,8 @@
test
- org.hibernate
- hibernate-core-jakarta
+ org.hibernate.orm
+ hibernate-core
org.glassfish.jaxb
@@ -94,7 +94,7 @@
useful as it helps to keep it shorter; also this should allow us to have slightly more flexibility
in experimenting with different version of Hibernate ORM -->
- org.hibernate
+ org.hibernate.orm
hibernate-graalvm
@@ -128,7 +128,7 @@
org.hibernate
- quarkus-local-cache-jakarta
+ quarkus-local-cache
*
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/FastBootHibernatePersistenceProvider.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/FastBootHibernatePersistenceProvider.java
index 638c099890056..511bb5b4086f6 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/FastBootHibernatePersistenceProvider.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/FastBootHibernatePersistenceProvider.java
@@ -326,7 +326,7 @@ private static String extractProviderName(Map integration) {
if (integration == null) {
return null;
}
- final String setting = (String) integration.get(AvailableSettings.JPA_PERSISTENCE_PROVIDER);
+ final String setting = (String) integration.get(AvailableSettings.JAKARTA_PERSISTENCE_PROVIDER);
return setting == null ? null : setting.trim();
}
@@ -351,7 +351,9 @@ private static void injectDataSource(String persistenceUnitName, String dataSour
if (runtimeSettingsBuilder.isConfigured(AvailableSettings.URL) ||
runtimeSettingsBuilder.isConfigured(AvailableSettings.DATASOURCE) ||
runtimeSettingsBuilder.isConfigured(AvailableSettings.JPA_JTA_DATASOURCE) ||
- runtimeSettingsBuilder.isConfigured(AvailableSettings.JPA_NON_JTA_DATASOURCE)) {
+ runtimeSettingsBuilder.isConfigured(AvailableSettings.JPA_NON_JTA_DATASOURCE) ||
+ runtimeSettingsBuilder.isConfigured(AvailableSettings.JAKARTA_JTA_DATASOURCE) ||
+ runtimeSettingsBuilder.isConfigured(AvailableSettings.JAKARTA_NON_JTA_DATASOURCE)) {
// the datasource has been defined in the persistence unit, we can bail out
return;
}
@@ -384,7 +386,7 @@ private static void injectRuntimeConfiguration(HibernateOrmRuntimeConfigPersiste
runtimeSettingsBuilder.put(AvailableSettings.JAKARTA_HBM2DDL_DATABASE_ACTION,
persistenceUnitConfig.database.generation.generation);
- runtimeSettingsBuilder.put(AvailableSettings.HBM2DDL_CREATE_SCHEMAS,
+ runtimeSettingsBuilder.put(AvailableSettings.JAKARTA_HBM2DDL_CREATE_SCHEMAS,
String.valueOf(persistenceUnitConfig.database.generation.createSchemas));
if (persistenceUnitConfig.database.generation.haltOnError) {
@@ -394,7 +396,7 @@ private static void injectRuntimeConfiguration(HibernateOrmRuntimeConfigPersiste
//Never append on existing scripts:
runtimeSettingsBuilder.put(AvailableSettings.HBM2DDL_SCRIPTS_CREATE_APPEND, "false");
- runtimeSettingsBuilder.put(AvailableSettings.HBM2DDL_SCRIPTS_ACTION,
+ runtimeSettingsBuilder.put(AvailableSettings.JAKARTA_HBM2DDL_SCRIPTS_ACTION,
persistenceUnitConfig.scripts.generation.generation);
if (persistenceUnitConfig.scripts.generation.createTarget.isPresent()) {
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootEntityManagerFactoryBuilder.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootEntityManagerFactoryBuilder.java
index a1542a51ff1d9..cff338c1986af 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootEntityManagerFactoryBuilder.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootEntityManagerFactoryBuilder.java
@@ -11,15 +11,15 @@
import org.hibernate.HibernateException;
import org.hibernate.Interceptor;
-import org.hibernate.MultiTenancyStrategy;
import org.hibernate.SessionFactory;
import org.hibernate.SessionFactoryObserver;
import org.hibernate.boot.internal.SessionFactoryOptionsBuilder;
+import org.hibernate.boot.model.process.spi.ManagedResources;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
+import org.hibernate.boot.spi.MetadataImplementor;
import org.hibernate.bytecode.internal.SessionFactoryObserverForBytecodeEnhancer;
import org.hibernate.bytecode.spi.BytecodeProvider;
-import org.hibernate.engine.query.spi.HQLQueryPlan;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.internal.SessionFactoryImpl;
import org.hibernate.jpa.boot.spi.EntityManagerFactoryBuilder;
@@ -34,6 +34,8 @@
import io.quarkus.arc.InjectableInstance;
import io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil;
import io.quarkus.hibernate.orm.runtime.RuntimeSettings;
+import io.quarkus.hibernate.orm.runtime.observers.SessionFactoryObserverForNamedQueryValidation;
+import io.quarkus.hibernate.orm.runtime.observers.SessionFactoryObserverForSchemaExport;
import io.quarkus.hibernate.orm.runtime.recording.PrevalidatedQuarkusMetadata;
import io.quarkus.hibernate.orm.runtime.tenant.HibernateCurrentTenantIdentifierResolver;
@@ -73,7 +75,7 @@ public EntityManagerFactory build() {
try {
final SessionFactoryOptionsBuilder optionsBuilder = metadata.buildSessionFactoryOptionsBuilder();
populate(persistenceUnitName, optionsBuilder, standardServiceRegistry);
- return new SessionFactoryImpl(metadata, optionsBuilder.buildOptions(), HQLQueryPlan::new);
+ return new SessionFactoryImpl(metadata, optionsBuilder.buildOptions());
} catch (Exception e) {
throw persistenceException("Unable to build Hibernate SessionFactory", e);
}
@@ -157,6 +159,12 @@ protected void populate(String persistenceUnitName, SessionFactoryOptionsBuilder
options.addSessionFactoryObservers(new ServiceRegistryCloser());
+ //New in ORM 6.2:
+ options.addSessionFactoryObservers(new SessionFactoryObserverForNamedQueryValidation(metadata));
+ options.addSessionFactoryObservers(new SessionFactoryObserverForSchemaExport(metadata));
+ //Vanilla ORM registers this one as well; we don't:
+ //options.addSessionFactoryObservers( new SessionFactoryObserverForRegistration() );
+
options.applyEntityNotFoundDelegate(new JpaEntityNotFoundDelegate());
// This is necessary for Hibernate Reactive, see https://github.com/quarkusio/quarkus/issues/15814
@@ -177,7 +185,7 @@ protected void populate(String persistenceUnitName, SessionFactoryOptionsBuilder
BytecodeProvider bytecodeProvider = ssr.getService(BytecodeProvider.class);
options.addSessionFactoryObservers(new SessionFactoryObserverForBytecodeEnhancer(bytecodeProvider));
- if (options.getMultiTenancyStrategy() != MultiTenancyStrategy.NONE) {
+ if (options.isMultiTenancyEnabled()) {
options.applyCurrentTenantIdentifierResolver(new HibernateCurrentTenantIdentifierResolver(persistenceUnitName));
}
@@ -212,10 +220,19 @@ public void sessionFactoryClosed(SessionFactory sessionFactory) {
private static class JpaEntityNotFoundDelegate implements EntityNotFoundDelegate, Serializable {
- @Override
- public void handleEntityNotFound(String entityName, Serializable id) {
+ public void handleEntityNotFound(String entityName, Object id) {
throw new EntityNotFoundException("Unable to find " + entityName + " with id " + id);
}
}
+ @Override
+ public ManagedResources getManagedResources() {
+ throw new IllegalStateException("This method is not available at runtime in Quarkus");
+ }
+
+ @Override
+ public MetadataImplementor metadata() {
+ return metadata;
+ }
+
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java
index 5f0cc59a39429..c45338a255bcf 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/FastBootMetadataBuilder.java
@@ -36,6 +36,7 @@
import org.hibernate.boot.MetadataSources;
import org.hibernate.boot.archive.scan.internal.StandardScanOptions;
import org.hibernate.boot.archive.scan.spi.Scanner;
+import org.hibernate.boot.beanvalidation.BeanValidationIntegrator;
import org.hibernate.boot.internal.MetadataImpl;
import org.hibernate.boot.model.process.spi.ManagedResources;
import org.hibernate.boot.model.process.spi.MetadataBuildingProcess;
@@ -46,11 +47,10 @@
import org.hibernate.boot.spi.MetadataBuilderImplementor;
import org.hibernate.cache.internal.CollectionCacheInvalidator;
import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.cfg.beanvalidation.BeanValidationIntegrator;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.connections.spi.MultiTenantConnectionProvider;
import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
-import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
+import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.EntityManagerMessageLogger;
import org.hibernate.internal.util.StringHelper;
@@ -81,6 +81,7 @@
import io.quarkus.hibernate.orm.runtime.recording.RecordableBootstrap;
import io.quarkus.hibernate.orm.runtime.recording.RecordedState;
import io.quarkus.hibernate.orm.runtime.recording.RecordingDialectFactory;
+import io.quarkus.hibernate.orm.runtime.service.QuarkusMutableIdentifierGeneratorFactory;
import io.quarkus.hibernate.orm.runtime.tenant.HibernateMultiTenantConnectionProvider;
/**
@@ -98,6 +99,8 @@ public class FastBootMetadataBuilder {
private static final String JACC_ENABLED = "hibernate.jacc.enabled";
@Deprecated
private static final String WRAP_RESULT_SETS = "hibernate.jdbc.wrap_result_sets";
+ @Deprecated
+ private static final String ALLOW_ENHANCEMENT_AS_PROXY = "hibernate.bytecode.allow_enhancement_as_proxy";
private static final EntityManagerMessageLogger LOG = messageLogger(FastBootMetadataBuilder.class);
@@ -107,7 +110,7 @@ public class FastBootMetadataBuilder {
private final ManagedResources managedResources;
private final MetadataBuilderImplementor metamodelBuilder;
private final Collection> additionalIntegrators;
- private final Collection providedServices;
+ private final Collection> providedServices;
private final PreGeneratedProxies preGeneratedProxies;
private final Optional dataSource;
private final boolean isReactive;
@@ -152,6 +155,13 @@ public FastBootMetadataBuilder(final QuarkusPersistenceUnitDefinition puDefiniti
}
ssrBuilder.applySetting(key, entry.getValue());
}
+ // We need to initialize the multi tenancy strategy before building the service registry as it is used to
+ // create metadata builder. Adding services afterwards would lead to unpredicted behavior.
+ final MultiTenancyStrategy multiTenancyStrategy = puDefinition.getMultitenancyStrategy();
+ if (multiTenancyStrategy != null && multiTenancyStrategy != MultiTenancyStrategy.NONE) {
+ ssrBuilder.addService(MultiTenantConnectionProvider.class,
+ new HibernateMultiTenantConnectionProvider(puDefinition.getName()));
+ }
this.standardServiceRegistry = ssrBuilder.build();
registerIdentifierGenerators(standardServiceRegistry);
@@ -208,12 +218,6 @@ public FastBootMetadataBuilder(final QuarkusPersistenceUnitDefinition puDefiniti
// for the time being we want to revoke access to the temp ClassLoader if one
// was passed
metamodelBuilder.applyTempClassLoader(null);
-
- final MultiTenancyStrategy multiTenancyStrategy = puDefinition.getMultitenancyStrategy();
- if (multiTenancyStrategy != null && multiTenancyStrategy != MultiTenancyStrategy.NONE) {
- ssrBuilder.addService(MultiTenantConnectionProvider.class,
- new HibernateMultiTenantConnectionProvider(puDefinition.getName()));
- }
}
/**
@@ -265,10 +269,10 @@ private MergedSettings mergeSettings(QuarkusPersistenceUnitDefinition puDefiniti
Boolean.getBoolean(AvailableSettings.ALLOW_UPDATE_OUTSIDE_TRANSACTION));
}
- //Enable the new Enhanced Proxies capability (unless it was specifically disabled):
- final String legacyALLOW_ENHANCEMENT_AS_PROXY = "hibernate.bytecode.allow_enhancement_as_proxy";
- if (!cfg.containsKey(legacyALLOW_ENHANCEMENT_AS_PROXY)) {
- cfg.put(legacyALLOW_ENHANCEMENT_AS_PROXY, Boolean.TRUE.toString());
+ if (cfg.containsKey(ALLOW_ENHANCEMENT_AS_PROXY)) {
+ LOG.warn("Setting '" + ALLOW_ENHANCEMENT_AS_PROXY
+ + "' is being ignored: this property is no longer meaningful since Hibernate ORM 6");
+ cfg.remove(ALLOW_ENHANCEMENT_AS_PROXY);
}
//Always Order batch updates as it prevents contention on the data (unless it was disabled)
if (!cfg.containsKey(AvailableSettings.ORDER_UPDATES)) {
@@ -289,12 +293,12 @@ private MergedSettings mergeSettings(QuarkusPersistenceUnitDefinition puDefiniti
*/
cfg.putIfAbsent(AvailableSettings.CONNECTION_HANDLING,
PhysicalConnectionHandlingMode.DELAYED_ACQUISITION_AND_RELEASE_BEFORE_TRANSACTION_COMPLETION);
-
- if (readBooleanConfigurationValue(cfg, WRAP_RESULT_SETS)) {
+ if (cfg.containsKey(WRAP_RESULT_SETS)) {
LOG.warn("Wrapping result sets is no longer supported by Hibernate ORM. Setting " + WRAP_RESULT_SETS
+
+ " is being ignored.");
+ cfg.remove(WRAP_RESULT_SETS);
}
- cfg.put(WRAP_RESULT_SETS, "false");
// XML mapping support can be costly, so we only enable it when XML mappings are actually used
// or when integrations (e.g. Envers) need it.
@@ -419,8 +423,8 @@ private PrevalidatedQuarkusMetadata trimBootstrapMetadata(MetadataImpl fullMeta)
MetadataImpl replacement = new MetadataImpl(
fullMeta.getUUID(),
fullMeta.getMetadataBuildingOptions(), //TODO Replace this
- fullMeta.getIdentifierGeneratorFactory(),
fullMeta.getEntityBindingMap(),
+ fullMeta.getComposites(),
fullMeta.getMappedSuperclassMap(),
fullMeta.getCollectionBindingMap(),
fullMeta.getTypeDefinitionMap(),
@@ -592,14 +596,19 @@ private void registerIdentifierGenerators(StandardServiceRegistry ssr) {
if (idGeneratorStrategyProviderSetting != null) {
final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider = strategySelector
.resolveStrategy(IdentifierGeneratorStrategyProvider.class, idGeneratorStrategyProviderSetting);
- final MutableIdentifierGeneratorFactory identifierGeneratorFactory = ssr
- .getService(MutableIdentifierGeneratorFactory.class);
+ final IdentifierGeneratorFactory identifierGeneratorFactory = ssr
+ .getService(IdentifierGeneratorFactory.class);
if (identifierGeneratorFactory == null) {
throw persistenceException("Application requested custom identifier generator strategies, "
+ "but the MutableIdentifierGeneratorFactory could not be found");
}
+ if (!(identifierGeneratorFactory instanceof QuarkusMutableIdentifierGeneratorFactory)) {
+ throw persistenceException(
+ "Unexpected implementation of IdentifierGeneratorFactory: do not override core components");
+ }
+ final QuarkusMutableIdentifierGeneratorFactory qIdGenerator = (QuarkusMutableIdentifierGeneratorFactory) identifierGeneratorFactory;
for (Map.Entry> entry : idGeneratorStrategyProvider.getStrategies().entrySet()) {
- identifierGeneratorFactory.register(entry.getKey(), entry.getValue());
+ qIdGenerator.register(entry.getKey(), entry.getValue());
}
}
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/registry/PreconfiguredServiceRegistryBuilder.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/registry/PreconfiguredServiceRegistryBuilder.java
index be0f31cc1b3cf..d9703d52d8c62 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/registry/PreconfiguredServiceRegistryBuilder.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/registry/PreconfiguredServiceRegistryBuilder.java
@@ -12,13 +12,12 @@
import org.hibernate.boot.registry.internal.StandardServiceRegistryImpl;
import org.hibernate.boot.registry.selector.internal.StrategySelectorImpl;
import org.hibernate.engine.config.internal.ConfigurationServiceInitiator;
-import org.hibernate.engine.jdbc.batch.internal.UnmodifiableBatchBuilderInitiator;
+import org.hibernate.engine.jdbc.batch.internal.BatchBuilderInitiator;
import org.hibernate.engine.jdbc.connections.internal.MultiTenantConnectionProviderInitiator;
import org.hibernate.engine.jdbc.cursor.internal.RefCursorSupportInitiator;
import org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator;
import org.hibernate.engine.jdbc.internal.JdbcServicesInitiator;
import org.hibernate.event.internal.EntityCopyObserverFactoryInitiator;
-import org.hibernate.hql.internal.QueryTranslatorFactoryInitiator;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.persister.internal.PersisterClassResolverInitiator;
import org.hibernate.persister.internal.PersisterFactoryInitiator;
@@ -29,18 +28,19 @@
import org.hibernate.tool.schema.internal.SchemaManagementToolInitiator;
import io.quarkus.hibernate.orm.runtime.cdi.QuarkusManagedBeanRegistryInitiator;
-import io.quarkus.hibernate.orm.runtime.customized.DisabledBytecodeProviderInitiator;
import io.quarkus.hibernate.orm.runtime.customized.QuarkusConnectionProviderInitiator;
import io.quarkus.hibernate.orm.runtime.customized.QuarkusJndiServiceInitiator;
import io.quarkus.hibernate.orm.runtime.customized.QuarkusJtaPlatformInitiator;
+import io.quarkus.hibernate.orm.runtime.customized.QuarkusRuntimeProxyFactoryFactory;
import io.quarkus.hibernate.orm.runtime.customized.QuarkusRuntimeProxyFactoryFactoryInitiator;
import io.quarkus.hibernate.orm.runtime.recording.RecordedState;
import io.quarkus.hibernate.orm.runtime.service.CfgXmlAccessServiceInitiatorQuarkus;
-import io.quarkus.hibernate.orm.runtime.service.DisabledJMXInitiator;
import io.quarkus.hibernate.orm.runtime.service.FlatClassLoaderService;
import io.quarkus.hibernate.orm.runtime.service.QuarkusImportSqlCommandExtractorInitiator;
+import io.quarkus.hibernate.orm.runtime.service.QuarkusMutationExecutorServiceInitiator;
import io.quarkus.hibernate.orm.runtime.service.QuarkusRegionFactoryInitiator;
import io.quarkus.hibernate.orm.runtime.service.QuarkusStaticDialectFactoryInitiator;
+import io.quarkus.hibernate.orm.runtime.service.bytecodeprovider.QuarkusRuntimeBytecodeProviderInitiator;
/**
* Helps to instantiate a ServiceRegistryBuilder from a previous state. This
@@ -53,9 +53,9 @@
*/
public class PreconfiguredServiceRegistryBuilder {
- private final Map configurationValues = new HashMap();
- private final List initiators;
- private final List providedServices = new ArrayList();
+ private final Map configurationValues = new HashMap<>();
+ private final List> initiators;
+ private final List> providedServices = new ArrayList>();
private final Collection integrators;
private final StandardServiceRegistryImpl destroyedRegistry;
@@ -78,7 +78,7 @@ public PreconfiguredServiceRegistryBuilder applySetting(String settingName, Obje
return this;
}
- public PreconfiguredServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
+ public PreconfiguredServiceRegistryBuilder addInitiator(StandardServiceInitiator> initiator) {
initiators.add(initiator);
return this;
}
@@ -88,7 +88,7 @@ public PreconfiguredServiceRegistryBuilder addIntegrator(Integrator integrator)
return this;
}
- public PreconfiguredServiceRegistryBuilder addService(ProvidedService providedService) {
+ public PreconfiguredServiceRegistryBuilder addService(ProvidedService> providedService) {
providedServices.add(providedService);
return this;
}
@@ -103,7 +103,7 @@ public StandardServiceRegistryImpl buildNewServiceRegistry() {
// already recorded as part of #applyIntegrator, #addInitiator, #addService
// applyServiceContributors( bootstrapServiceRegistry );
- final Map settingsCopy = new HashMap();
+ final Map settingsCopy = new HashMap<>();
settingsCopy.putAll(configurationValues);
destroyedRegistry.resetAndReactivate(bootstrapServiceRegistry, initiators, providedServices, settingsCopy);
@@ -142,14 +142,23 @@ private BootstrapServiceRegistry buildEmptyBootstrapServiceRegistry() {
*
* @return
*/
- private static List buildQuarkusServiceInitiatorList(RecordedState rs) {
- final ArrayList serviceInitiators = new ArrayList();
+ private static List> buildQuarkusServiceInitiatorList(RecordedState rs) {
+ final ArrayList> serviceInitiators = new ArrayList>();
- //Enforces no bytecode enhancement will happen at runtime:
- serviceInitiators.add(DisabledBytecodeProviderInitiator.INSTANCE);
+ //References to this object need to be injected in both the initiator for BytecodeProvider and for
+ //the registered ProxyFactoryFactoryInitiator
+ QuarkusRuntimeProxyFactoryFactory statefulProxyFactory = new QuarkusRuntimeProxyFactoryFactory(
+ rs.getProxyClassDefinitions());
+
+ //Enforces no bytecode enhancement will happen at runtime,
+ //but allows use of proxies generated at build time
+ serviceInitiators.add(new QuarkusRuntimeBytecodeProviderInitiator(statefulProxyFactory));
+
+ //Routes to the standard implementation, but w/o allowing configuration options to override it
+ serviceInitiators.add(QuarkusMutationExecutorServiceInitiator.INSTANCE);
//Use a custom ProxyFactoryFactory which is able to use the class definitions we already created:
- serviceInitiators.add(new QuarkusRuntimeProxyFactoryFactoryInitiator(rs));
+ serviceInitiators.add(new QuarkusRuntimeProxyFactoryFactoryInitiator(statefulProxyFactory));
// Replaces org.hibernate.boot.cfgxml.internal.CfgXmlAccessServiceInitiator :
// not used
@@ -174,9 +183,6 @@ private static List buildQuarkusServiceInitiatorList(R
// Custom one!
serviceInitiators.add(QuarkusJndiServiceInitiator.INSTANCE);
- // Custom one!
- serviceInitiators.add(DisabledJMXInitiator.INSTANCE);
-
serviceInitiators.add(PersisterClassResolverInitiator.INSTANCE);
serviceInitiators.add(PersisterFactoryInitiator.INSTANCE);
@@ -190,14 +196,12 @@ private static List buildQuarkusServiceInitiatorList(R
// Custom one: Dialect is injected explicitly
serviceInitiators.add(new QuarkusStaticDialectFactoryInitiator(rs.getDialect()));
- // Non-default implementation: optimised for lack of JMX management
- serviceInitiators.add(UnmodifiableBatchBuilderInitiator.INSTANCE);
+ // Default implementation
+ serviceInitiators.add(BatchBuilderInitiator.INSTANCE);
serviceInitiators.add(JdbcServicesInitiator.INSTANCE);
serviceInitiators.add(RefCursorSupportInitiator.INSTANCE);
- serviceInitiators.add(QueryTranslatorFactoryInitiator.INSTANCE);
-
// Disabled: IdentifierGenerators are no longer initiated after Metadata was generated.
// serviceInitiators.add(MutableIdentifierGeneratorFactoryInitiator.INSTANCE);
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/xml/RecordableXmlMapping.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/xml/RecordableXmlMapping.java
index f185c9f1d5d7b..be4e57bcbad95 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/xml/RecordableXmlMapping.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/boot/xml/RecordableXmlMapping.java
@@ -3,7 +3,7 @@
import org.hibernate.boot.jaxb.Origin;
import org.hibernate.boot.jaxb.SourceType;
import org.hibernate.boot.jaxb.hbm.spi.JaxbHbmHibernateMapping;
-import org.hibernate.boot.jaxb.mapping.spi.JaxbEntityMappings;
+import org.hibernate.boot.jaxb.mapping.JaxbEntityMappings;
import org.hibernate.boot.jaxb.spi.Binding;
import io.quarkus.runtime.annotations.RecordableConstructor;
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/cdi/QuarkusManagedBeanRegistry.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/cdi/QuarkusManagedBeanRegistry.java
index b7043f59ad7fb..ba85708f44b98 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/cdi/QuarkusManagedBeanRegistry.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/cdi/QuarkusManagedBeanRegistry.java
@@ -3,6 +3,7 @@
import org.hibernate.resource.beans.container.spi.BeanContainer;
import org.hibernate.resource.beans.container.spi.ContainedBean;
import org.hibernate.resource.beans.internal.FallbackBeanInstanceProducer;
+import org.hibernate.resource.beans.spi.BeanInstanceProducer;
import org.hibernate.resource.beans.spi.ManagedBean;
import org.hibernate.resource.beans.spi.ManagedBeanRegistry;
@@ -30,16 +31,12 @@ public QuarkusManagedBeanRegistry() {
@Override
public ManagedBean getBean(Class beanClass) {
- return new ContainedBeanManagedBeanAdapter<>(beanClass,
- beanContainer.getBean(beanClass, QuarkusBeanContainerLifecycleOptions.INSTANCE,
- FallbackBeanInstanceProducer.INSTANCE));
+ return getBean(beanClass, FallbackBeanInstanceProducer.INSTANCE);
}
@Override
public ManagedBean getBean(String beanName, Class beanContract) {
- return new ContainedBeanManagedBeanAdapter<>(beanContract,
- beanContainer.getBean(beanName, beanContract, QuarkusBeanContainerLifecycleOptions.INSTANCE,
- FallbackBeanInstanceProducer.INSTANCE));
+ return getBean(beanName, beanContract, FallbackBeanInstanceProducer.INSTANCE);
}
@Override
@@ -47,6 +44,21 @@ public BeanContainer getBeanContainer() {
return beanContainer;
}
+ @Override
+ public ManagedBean getBean(Class beanClass, BeanInstanceProducer fallbackBeanInstanceProducer) {
+ return new ContainedBeanManagedBeanAdapter<>(beanClass,
+ beanContainer.getBean(beanClass, QuarkusBeanContainerLifecycleOptions.INSTANCE,
+ fallbackBeanInstanceProducer));
+ }
+
+ @Override
+ public ManagedBean getBean(String beanName, Class beanContract,
+ BeanInstanceProducer fallbackBeanInstanceProducer) {
+ return new ContainedBeanManagedBeanAdapter<>(beanContract,
+ beanContainer.getBean(beanName, beanContract, QuarkusBeanContainerLifecycleOptions.INSTANCE,
+ fallbackBeanInstanceProducer));
+ }
+
private static class ContainedBeanManagedBeanAdapter implements ManagedBean {
private final Class beanClass;
private final ContainedBean containedBean;
@@ -88,4 +100,5 @@ public boolean canUseCachedReferences() {
return false;
}
}
+
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusDialectSelector.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusDialectSelector.java
new file mode 100644
index 0000000000000..17488d4559cfa
--- /dev/null
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusDialectSelector.java
@@ -0,0 +1,37 @@
+package io.quarkus.hibernate.orm.runtime.customized;
+
+import java.util.Objects;
+
+import org.hibernate.boot.registry.selector.internal.DefaultDialectSelector;
+import org.hibernate.dialect.Dialect;
+import org.jboss.logging.Logger;
+
+import io.quarkus.hibernate.orm.runtime.dialect.QuarkusH2Dialect;
+
+/**
+ * Customizes the DefaultDialectSelector to ensure we use the custom Quarkus dialect for H2;
+ * this is necessary as we need to strictly match the H2 version bundled with Quarkus:
+ * normally Hibernate ORM would match this from connection metadata, but we don't have that metadata.
+ */
+final class QuarkusDialectSelector extends DefaultDialectSelector {
+
+ @Override
+ public Class extends Dialect> resolve(final String name) {
+ Objects.requireNonNull(name);
+ if (name.isEmpty()) {
+ return null;
+ }
+ switch (name) {
+ case "org.hibernate.dialect.H2Dialect":
+ Logger.getLogger(QuarkusDialectSelector.class)
+ .warn("Overriding dialect choice: 'org.hibernate.dialect.H2Dialect' will be replaced with '"
+ + QuarkusH2Dialect.class.getName()
+ + "' to ensure compatibility with the bundled version of H2.");
+ case "H2":
+ return QuarkusH2Dialect.class;
+ default:
+ return super.resolve(name);
+ }
+ }
+
+}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusProxyFactory.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusProxyFactory.java
index 6fa654037c9f5..e6321bdb460fc 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusProxyFactory.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusProxyFactory.java
@@ -2,7 +2,6 @@
import static org.hibernate.internal.CoreLogging.messageLogger;
-import java.io.Serializable;
import java.lang.reflect.Constructor;
import java.lang.reflect.Method;
import java.util.Set;
@@ -31,9 +30,9 @@ public final class QuarkusProxyFactory implements ProxyFactory {
private final ProxyDefinitions proxyClassDefinitions;
- private Class persistentClass;
+ private Class> persistentClass;
private String entityName;
- private Class[] interfaces;
+ private Class>[] interfaces;
private Method getIdentifierMethod;
private Method setIdentifierMethod;
private CompositeType componentIdType;
@@ -47,7 +46,8 @@ public QuarkusProxyFactory(ProxyDefinitions proxyClassDefinitions) {
}
@Override
- public void postInstantiate(String entityName, Class persistentClass, Set interfaces, Method getIdentifierMethod,
+ public void postInstantiate(String entityName, Class> persistentClass, Set> interfaces,
+ Method getIdentifierMethod,
Method setIdentifierMethod, CompositeType componentIdType) throws HibernateException {
this.entityName = entityName;
this.persistentClass = persistentClass;
@@ -65,7 +65,7 @@ public void postInstantiate(String entityName, Class persistentClass, Set
}
- private Class[] toArray(Set interfaces) {
+ private static Class>[] toArray(Set> interfaces) {
if (interfaces == null) {
return ArrayHelper.EMPTY_CLASS_ARRAY;
}
@@ -75,7 +75,7 @@ private Class[] toArray(Set interfaces) {
@Override
public HibernateProxy getProxy(
- Serializable id,
+ Object id,
SharedSessionContractImplementor session) throws HibernateException {
final ByteBuddyInterceptor interceptor = new ByteBuddyInterceptor(
entityName,
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusRuntimeProxyFactoryFactory.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusRuntimeProxyFactoryFactory.java
index 392155d5b6e2e..e8e933ab5d6f0 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusRuntimeProxyFactoryFactory.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusRuntimeProxyFactoryFactory.java
@@ -27,12 +27,6 @@ public ProxyFactory buildProxyFactory(SessionFactoryImplementor sessionFactory)
return new QuarkusProxyFactory(proxyClassDefinitions);
}
- @Deprecated
- @Override
- public BasicProxyFactory buildBasicProxyFactory(Class superClass, Class[] interfaces) {
- return null;
- }
-
@Override
public BasicProxyFactory buildBasicProxyFactory(Class aClass) {
return null;
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusRuntimeProxyFactoryFactoryInitiator.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusRuntimeProxyFactoryFactoryInitiator.java
index 5109202409424..ce60e02b0d9af 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusRuntimeProxyFactoryFactoryInitiator.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusRuntimeProxyFactoryFactoryInitiator.java
@@ -6,9 +6,6 @@
import org.hibernate.bytecode.spi.ProxyFactoryFactory;
import org.hibernate.service.spi.ServiceRegistryImplementor;
-import io.quarkus.hibernate.orm.runtime.proxies.ProxyDefinitions;
-import io.quarkus.hibernate.orm.runtime.recording.RecordedState;
-
/**
* Responsible for initializing the QuarkusRuntimeProxyFactoryFactory.
* N.B. : this is a stateful Service Initiator, it carries the proxy definitions which have been
@@ -16,15 +13,15 @@
*/
public final class QuarkusRuntimeProxyFactoryFactoryInitiator implements StandardServiceInitiator {
- private final ProxyDefinitions proxyClassDefinitions;
+ private final QuarkusRuntimeProxyFactoryFactory proxyFactoryFactory;
- public QuarkusRuntimeProxyFactoryFactoryInitiator(RecordedState rs) {
- proxyClassDefinitions = rs.getProxyClassDefinitions();
+ public QuarkusRuntimeProxyFactoryFactoryInitiator(QuarkusRuntimeProxyFactoryFactory proxyFactoryFactory) {
+ this.proxyFactoryFactory = proxyFactoryFactory;
}
@Override
public ProxyFactoryFactory initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
- return new QuarkusRuntimeProxyFactoryFactory(proxyClassDefinitions);
+ return proxyFactoryFactory;
}
@Override
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusStrategySelectorBuilder.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusStrategySelectorBuilder.java
index 0daf40a7b4592..17b6995127fb4 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusStrategySelectorBuilder.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/customized/QuarkusStrategySelectorBuilder.java
@@ -3,10 +3,12 @@
import org.hibernate.boot.model.naming.ImplicitNamingStrategy;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl;
import org.hibernate.boot.model.naming.ImplicitNamingStrategyJpaCompliantImpl;
+import org.hibernate.boot.model.relational.ColumnOrderingStrategy;
+import org.hibernate.boot.model.relational.ColumnOrderingStrategyLegacy;
+import org.hibernate.boot.model.relational.ColumnOrderingStrategyStandard;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.selector.StrategyRegistration;
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
-import org.hibernate.boot.registry.selector.internal.DefaultDialectSelector;
import org.hibernate.boot.registry.selector.internal.DefaultJtaPlatformSelector;
import org.hibernate.boot.registry.selector.internal.StrategySelectorImpl;
import org.hibernate.boot.registry.selector.spi.StrategySelector;
@@ -15,13 +17,23 @@
import org.hibernate.cache.spi.CacheKeysFactory;
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
-import org.hibernate.hql.spi.id.MultiTableBulkIdStrategy;
-import org.hibernate.hql.spi.id.global.GlobalTemporaryTableBulkIdStrategy;
-import org.hibernate.hql.spi.id.local.LocalTemporaryTableBulkIdStrategy;
-import org.hibernate.hql.spi.id.persistent.PersistentTableBulkIdStrategy;
+import org.hibernate.id.enhanced.ImplicitDatabaseObjectNamingStrategy;
+import org.hibernate.id.enhanced.LegacyNamingStrategy;
+import org.hibernate.id.enhanced.SingleNamingStrategy;
+import org.hibernate.id.enhanced.StandardNamingStrategy;
+import org.hibernate.query.sqm.mutation.internal.cte.CteMutationStrategy;
+import org.hibernate.query.sqm.mutation.internal.temptable.GlobalTemporaryTableMutationStrategy;
+import org.hibernate.query.sqm.mutation.internal.temptable.LocalTemporaryTableMutationStrategy;
+import org.hibernate.query.sqm.mutation.internal.temptable.PersistentTableMutationStrategy;
+import org.hibernate.query.sqm.mutation.spi.SqmMultiTableMutationStrategy;
import org.hibernate.resource.transaction.backend.jdbc.internal.JdbcResourceLocalTransactionCoordinatorBuilderImpl;
import org.hibernate.resource.transaction.backend.jta.internal.JtaTransactionCoordinatorBuilderImpl;
import org.hibernate.resource.transaction.spi.TransactionCoordinatorBuilder;
+import org.hibernate.type.format.FormatMapper;
+import org.hibernate.type.format.jackson.JacksonJsonFormatMapper;
+import org.hibernate.type.format.jackson.JacksonXmlFormatMapper;
+import org.hibernate.type.format.jakartajson.JsonBJsonFormatMapper;
+import org.hibernate.type.format.jaxb.JaxbXmlFormatMapper;
/**
* Similar to {@link org.hibernate.boot.registry.selector.internal.StrategySelectorBuilder} but
@@ -44,17 +56,22 @@ public static StrategySelector buildSelector(ClassLoaderService classLoaderServi
final StrategySelectorImpl strategySelector = new StrategySelectorImpl(classLoaderService);
// build the baseline...
- strategySelector.registerStrategyLazily(Dialect.class, new DefaultDialectSelector());
+ strategySelector.registerStrategyLazily(
+ Dialect.class,
+ new QuarkusDialectSelector());
strategySelector.registerStrategyLazily(JtaPlatform.class, new DefaultJtaPlatformSelector());
addTransactionCoordinatorBuilders(strategySelector);
- addMultiTableBulkIdStrategies(strategySelector);
+ addSqmMultiTableMutationStrategies(strategySelector);
addImplicitNamingStrategies(strategySelector);
+ addColumnOrderingStrategies(strategySelector);
addCacheKeysFactories(strategySelector);
+ addJsonFormatMappers(strategySelector);
+ addXmlFormatMappers(strategySelector);
// Required to support well known extensions e.g. Envers
// TODO: should we introduce a new integrator SPI to limit these to extensions supported by Quarkus?
for (StrategyRegistrationProvider provider : classLoaderService.loadJavaServices(StrategyRegistrationProvider.class)) {
- for (StrategyRegistration discoveredStrategyRegistration : provider.getStrategyRegistrations()) {
+ for (StrategyRegistration> discoveredStrategyRegistration : provider.getStrategyRegistrations()) {
applyFromStrategyRegistration(strategySelector, discoveredStrategyRegistration);
}
}
@@ -85,19 +102,23 @@ private static void addTransactionCoordinatorBuilders(StrategySelectorImpl strat
JtaTransactionCoordinatorBuilderImpl.class);
}
- private static void addMultiTableBulkIdStrategies(StrategySelectorImpl strategySelector) {
+ private static void addSqmMultiTableMutationStrategies(StrategySelectorImpl strategySelector) {
strategySelector.registerStrategyImplementor(
- MultiTableBulkIdStrategy.class,
- PersistentTableBulkIdStrategy.SHORT_NAME,
- PersistentTableBulkIdStrategy.class);
+ SqmMultiTableMutationStrategy.class,
+ CteMutationStrategy.SHORT_NAME,
+ CteMutationStrategy.class);
strategySelector.registerStrategyImplementor(
- MultiTableBulkIdStrategy.class,
- GlobalTemporaryTableBulkIdStrategy.SHORT_NAME,
- GlobalTemporaryTableBulkIdStrategy.class);
+ SqmMultiTableMutationStrategy.class,
+ GlobalTemporaryTableMutationStrategy.SHORT_NAME,
+ GlobalTemporaryTableMutationStrategy.class);
strategySelector.registerStrategyImplementor(
- MultiTableBulkIdStrategy.class,
- LocalTemporaryTableBulkIdStrategy.SHORT_NAME,
- LocalTemporaryTableBulkIdStrategy.class);
+ SqmMultiTableMutationStrategy.class,
+ LocalTemporaryTableMutationStrategy.SHORT_NAME,
+ LocalTemporaryTableMutationStrategy.class);
+ strategySelector.registerStrategyImplementor(
+ SqmMultiTableMutationStrategy.class,
+ PersistentTableMutationStrategy.SHORT_NAME,
+ PersistentTableMutationStrategy.class);
}
private static void addImplicitNamingStrategies(StrategySelectorImpl strategySelector) {
@@ -113,6 +134,29 @@ private static void addImplicitNamingStrategies(StrategySelectorImpl strategySel
ImplicitNamingStrategy.class,
"component-path",
ImplicitNamingStrategyComponentPathImpl.class);
+ strategySelector.registerStrategyImplementor(
+ ImplicitDatabaseObjectNamingStrategy.class,
+ StandardNamingStrategy.STRATEGY_NAME,
+ StandardNamingStrategy.class);
+ strategySelector.registerStrategyImplementor(
+ ImplicitDatabaseObjectNamingStrategy.class,
+ SingleNamingStrategy.STRATEGY_NAME,
+ SingleNamingStrategy.class);
+ strategySelector.registerStrategyImplementor(
+ ImplicitDatabaseObjectNamingStrategy.class,
+ LegacyNamingStrategy.STRATEGY_NAME,
+ LegacyNamingStrategy.class);
+ }
+
+ private static void addColumnOrderingStrategies(StrategySelectorImpl strategySelector) {
+ strategySelector.registerStrategyImplementor(
+ ColumnOrderingStrategy.class,
+ "default",
+ ColumnOrderingStrategyStandard.class);
+ strategySelector.registerStrategyImplementor(
+ ColumnOrderingStrategy.class,
+ "legacy",
+ ColumnOrderingStrategyLegacy.class);
}
private static void addCacheKeysFactories(StrategySelectorImpl strategySelector) {
@@ -126,4 +170,26 @@ private static void addCacheKeysFactories(StrategySelectorImpl strategySelector)
SimpleCacheKeysFactory.class);
}
+ private static void addJsonFormatMappers(StrategySelectorImpl strategySelector) {
+ strategySelector.registerStrategyImplementor(
+ FormatMapper.class,
+ JacksonJsonFormatMapper.SHORT_NAME,
+ JacksonJsonFormatMapper.class);
+ strategySelector.registerStrategyImplementor(
+ FormatMapper.class,
+ JsonBJsonFormatMapper.SHORT_NAME,
+ JsonBJsonFormatMapper.class);
+ }
+
+ private static void addXmlFormatMappers(StrategySelectorImpl strategySelector) {
+ strategySelector.registerStrategyImplementor(
+ FormatMapper.class,
+ JacksonXmlFormatMapper.SHORT_NAME,
+ JacksonXmlFormatMapper.class);
+ strategySelector.registerStrategyImplementor(
+ FormatMapper.class,
+ JaxbXmlFormatMapper.SHORT_NAME,
+ JaxbXmlFormatMapper.class);
+ }
+
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/devconsole/HibernateOrmDevConsoleInfoSupplier.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/devconsole/HibernateOrmDevConsoleInfoSupplier.java
index d50a1ab2c8d30..dd6ae38ff3ada 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/devconsole/HibernateOrmDevConsoleInfoSupplier.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/devconsole/HibernateOrmDevConsoleInfoSupplier.java
@@ -6,6 +6,7 @@
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
+import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@@ -13,14 +14,29 @@
import org.hibernate.LockOptions;
import org.hibernate.boot.Metadata;
-import org.hibernate.engine.spi.NamedQueryDefinition;
-import org.hibernate.engine.spi.NamedSQLQueryDefinition;
+import org.hibernate.boot.query.NamedHqlQueryDefinition;
+import org.hibernate.boot.query.NamedNativeQueryDefinition;
+import org.hibernate.boot.query.NamedQueryDefinition;
+import org.hibernate.boot.spi.AbstractNamedQueryDefinition;
+import org.hibernate.cfg.AvailableSettings;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.tool.hbm2ddl.SchemaExport;
+import org.hibernate.tool.schema.Action;
+import org.hibernate.tool.schema.SourceType;
import org.hibernate.tool.schema.TargetType;
+import org.hibernate.tool.schema.internal.ExceptionHandlerCollectingImpl;
+import org.hibernate.tool.schema.internal.HibernateSchemaManagementTool;
import org.hibernate.tool.schema.internal.exec.ScriptTargetOutputToWriter;
+import org.hibernate.tool.schema.spi.ContributableMatcher;
+import org.hibernate.tool.schema.spi.ExecutionOptions;
+import org.hibernate.tool.schema.spi.SchemaCreator;
+import org.hibernate.tool.schema.spi.SchemaDropper;
+import org.hibernate.tool.schema.spi.SchemaManagementTool;
+import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
+import org.hibernate.tool.schema.spi.ScriptSourceInput;
import org.hibernate.tool.schema.spi.ScriptTargetOutput;
+import org.hibernate.tool.schema.spi.SourceDescriptor;
import org.hibernate.tool.schema.spi.TargetDescriptor;
import io.quarkus.hibernate.orm.runtime.PersistenceUnitUtil;
@@ -37,17 +53,25 @@ public static void pushPersistenceUnit(String persistenceUnitName,
}
List namedQueries = new ArrayList<>();
- for (NamedQueryDefinition queryDefinition : metadata.getNamedQueryDefinitions()) {
- namedQueries.add(new QueryInfo(queryDefinition));
+ {
+ List namedQueriesHqlDefs = new ArrayList<>();
+ metadata.visitNamedHqlQueryDefinitions(namedQueriesHqlDefs::add);
+ for (NamedHqlQueryDefinition queryDefinition : namedQueriesHqlDefs) {
+ namedQueries.add(new QueryInfo(queryDefinition));
+ }
}
List namedNativeQueries = new ArrayList<>();
- for (NamedSQLQueryDefinition staticQueryDefinition : metadata.getNamedNativeQueryDefinitions()) {
- namedNativeQueries.add(new QueryInfo(staticQueryDefinition));
+ {
+ List namedNativeQueriesNativeDefs = new ArrayList<>();
+ metadata.visitNamedNativeQueryDefinitions(namedNativeQueriesNativeDefs::add);
+ for (NamedNativeQueryDefinition staticQueryDefinition : namedNativeQueriesNativeDefs) {
+ namedNativeQueries.add(new QueryInfo(staticQueryDefinition));
+ }
}
- String createDDL = generateDDL(SchemaExport.Action.CREATE, metadata, serviceRegistry, importFile);
- String dropDDL = generateDDL(SchemaExport.Action.DROP, metadata, serviceRegistry, importFile);
+ String createDDL = generateDDL(Action.CREATE, metadata, serviceRegistry, importFile);
+ String dropDDL = generateDDL(Action.DROP, metadata, serviceRegistry, importFile);
INSTANCE.persistenceUnits.put(persistenceUnitName, new PersistenceUnitInfo(persistenceUnitName, managedEntities,
namedQueries, namedNativeQueries, createDDL, dropDDL));
@@ -57,37 +81,61 @@ public static void clearData() {
INSTANCE.persistenceUnits.clear();
}
- private static String generateDDL(SchemaExport.Action action, Metadata metadata, ServiceRegistry serviceRegistry,
+ private static String generateDDL(Action action, Metadata metadata, ServiceRegistry ssr,
String importFiles) {
- SchemaExport schemaExport = new SchemaExport();
- schemaExport.setFormat(true);
- schemaExport.setDelimiter(";");
- schemaExport.setImportFiles(importFiles);
- StringWriter writer = new StringWriter();
+ //TODO see https://hibernate.atlassian.net/browse/HHH-16207
+ final HibernateSchemaManagementTool tool = (HibernateSchemaManagementTool) ssr.getService(SchemaManagementTool.class);
+ Map config = new HashMap<>(ssr.getService(ConfigurationService.class).getSettings());
+ config.put(AvailableSettings.HBM2DDL_DELIMITER, ";");
+ config.put(AvailableSettings.FORMAT_SQL, true);
+ config.put(AvailableSettings.HBM2DDL_IMPORT_FILES, importFiles);
+ ExceptionHandlerCollectingImpl exceptionHandler = new ExceptionHandlerCollectingImpl();
try {
- schemaExport.doExecution(action, false, metadata, serviceRegistry,
- new TargetDescriptor() {
+ final ExecutionOptions executionOptions = SchemaManagementToolCoordinator.buildExecutionOptions(
+ config,
+ exceptionHandler);
+ StringWriter writer = new StringWriter();
+ final SourceDescriptor source = new SourceDescriptor() {
+ @Override
+ public SourceType getSourceType() {
+ return SourceType.METADATA;
+ }
+
+ @Override
+ public ScriptSourceInput getScriptSourceInput() {
+ return null;
+ }
+ };
+ final TargetDescriptor target = new TargetDescriptor() {
+ @Override
+ public EnumSet getTargetTypes() {
+ return EnumSet.of(TargetType.SCRIPT);
+ }
+
+ @Override
+ public ScriptTargetOutput getScriptTargetOutput() {
+ return new ScriptTargetOutputToWriter(writer) {
@Override
- public EnumSet getTargetTypes() {
- return EnumSet.of(TargetType.SCRIPT);
+ public void accept(String command) {
+ super.accept(command);
}
-
- @Override
- public ScriptTargetOutput getScriptTargetOutput() {
- return new ScriptTargetOutputToWriter(writer) {
- @Override
- public void accept(String command) {
- super.accept(command);
- }
- };
- }
- });
+ };
+ }
+ };
+ if (action == Action.DROP) {
+ SchemaDropper schemaDropper = tool.getSchemaDropper(executionOptions.getConfigurationValues());
+ schemaDropper.doDrop(metadata, executionOptions, ContributableMatcher.ALL, source, target);
+ } else if (action == Action.CREATE) {
+ SchemaCreator schemaDropper = tool.getSchemaCreator(executionOptions.getConfigurationValues());
+ schemaDropper.doCreation(metadata, executionOptions, ContributableMatcher.ALL, source, target);
+ }
+ return writer.toString();
} catch (RuntimeException e) {
+ //TODO unroll the exceptionHandler ?
StringWriter stackTraceWriter = new StringWriter();
e.printStackTrace(new PrintWriter(stackTraceWriter));
return "Could not generate DDL: \n" + stackTraceWriter.toString();
}
- return writer.toString();
}
@Override
@@ -196,15 +244,20 @@ public static class QueryInfo {
private final String lockMode;
private final String type;
- public QueryInfo(NamedQueryDefinition queryDefinition) {
- this.name = queryDefinition.getName();
- this.query = queryDefinition.getQuery();
- this.cacheable = queryDefinition.isCacheable();
- LockOptions lockOptions = queryDefinition.getLockOptions();
- this.lockMode = lockOptions != null && lockOptions.getLockMode() != null
- ? lockOptions.getLockMode().name()
- : "";
- this.type = queryDefinition instanceof NamedSQLQueryDefinition ? "native" : "JPQL";
+ public QueryInfo(NamedHqlQueryDefinition queryDefinition) {
+ this.name = queryDefinition.getRegistrationName();
+ this.query = queryDefinition.getHqlString();
+ this.cacheable = extractIsCacheable(queryDefinition);
+ this.lockMode = extractLockOptions(queryDefinition);
+ this.type = "JPQL";
+ }
+
+ public QueryInfo(NamedNativeQueryDefinition nativeQueryDefinition) {
+ this.name = nativeQueryDefinition.getRegistrationName();
+ this.query = nativeQueryDefinition.getSqlQueryString();
+ this.cacheable = extractIsCacheable(nativeQueryDefinition);
+ this.lockMode = extractLockOptions(nativeQueryDefinition);
+ this.type = "native";
}
public String getName() {
@@ -228,4 +281,27 @@ public String getType() {
}
}
+
+ private static boolean extractIsCacheable(NamedQueryDefinition definition) {
+ //TODO cleanup and expose this properly in an SPI/API?
+ if (definition instanceof AbstractNamedQueryDefinition) {
+ AbstractNamedQueryDefinition def = (AbstractNamedQueryDefinition) definition;
+ if (def.getCacheable() == Boolean.TRUE) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private static String extractLockOptions(NamedQueryDefinition definition) {
+ //TODO cleanup and expose this properly in an SPI/API?
+ if (definition instanceof AbstractNamedQueryDefinition) {
+ final AbstractNamedQueryDefinition def = (AbstractNamedQueryDefinition) definition;
+ final LockOptions lockOptions = def.getLockOptions();
+ if (lockOptions != null && lockOptions.getLockMode() != null) {
+ return lockOptions.getLockMode().name();
+ }
+ }
+ return "";
+ }
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusH2Dialect.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusH2Dialect.java
index 70ee35c14da4b..ab36e761d235c 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusH2Dialect.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusH2Dialect.java
@@ -3,6 +3,7 @@
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
+import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.H2Dialect;
import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy;
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
@@ -16,6 +17,11 @@
* @author Emmanuel Bernard emmanuel@hibernate.org
*/
public class QuarkusH2Dialect extends H2Dialect {
+
+ public QuarkusH2Dialect() {
+ super(DatabaseVersion.make(2, 1, 210));
+ }
+
@Override
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData)
throws SQLException {
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusPostgreSQL10Dialect.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusPostgreSQL10Dialect.java
index 660e48cdb7e68..cb2f1945f262e 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusPostgreSQL10Dialect.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusPostgreSQL10Dialect.java
@@ -3,7 +3,8 @@
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
-import org.hibernate.dialect.PostgreSQL10Dialect;
+import org.hibernate.dialect.DatabaseVersion;
+import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy;
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
@@ -13,7 +14,12 @@
* This is PostgreSQL's behavior.
* See https://github.com/quarkusio/quarkus/issues/1886
*/
-public class QuarkusPostgreSQL10Dialect extends PostgreSQL10Dialect {
+public class QuarkusPostgreSQL10Dialect extends PostgreSQLDialect {
+
+ public QuarkusPostgreSQL10Dialect() {
+ super(DatabaseVersion.make(10, 0));
+ }
+
@Override
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData)
throws SQLException {
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusPostgreSQL95Dialect.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusPostgreSQL95Dialect.java
index 1e0f185f7a36a..2969ad85ffdbf 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusPostgreSQL95Dialect.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/dialect/QuarkusPostgreSQL95Dialect.java
@@ -3,7 +3,9 @@
import java.sql.DatabaseMetaData;
import java.sql.SQLException;
+import org.hibernate.dialect.DatabaseVersion;
import org.hibernate.dialect.PostgreSQL95Dialect;
+import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.engine.jdbc.env.spi.IdentifierCaseStrategy;
import org.hibernate.engine.jdbc.env.spi.IdentifierHelper;
import org.hibernate.engine.jdbc.env.spi.IdentifierHelperBuilder;
@@ -16,7 +18,12 @@
* @author Stephane Epardaud
* @author Emmanuel Bernard emmanuel@hibernate.org
*/
-public class QuarkusPostgreSQL95Dialect extends PostgreSQL95Dialect {
+public class QuarkusPostgreSQL95Dialect extends PostgreSQLDialect {
+
+ public QuarkusPostgreSQL95Dialect() {
+ super(DatabaseVersion.make(9, 5));
+ }
+
@Override
public IdentifierHelper buildIdentifierHelper(IdentifierHelperBuilder builder, DatabaseMetaData dbMetaData)
throws SQLException {
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/DisableLoggingFeature.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/DisableLoggingFeature.java
index 3b78d11627a22..50acd745f0063 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/DisableLoggingFeature.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/DisableLoggingFeature.java
@@ -1,6 +1,5 @@
package io.quarkus.hibernate.orm.runtime.graal;
-import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
@@ -16,7 +15,8 @@ public class DisableLoggingFeature implements Feature {
private static final String[] CATEGORIES = {
"org.hibernate.Version",
"org.hibernate.annotations.common.Version",
- "org.hibernate.dialect.Dialect"
+ "SQL dialect",
+ "org.hibernate.cfg.Environment"
};
private final Map categoryMap = new HashMap<>(CATEGORIES.length);
@@ -43,6 +43,6 @@ public void afterAnalysis(AfterAnalysisAccess access) {
@Override
public String getDescription() {
- return "Disables INFO logging during the analysis phase for the " + Arrays.toString(CATEGORIES) + " categories";
+ return "Disables INFO logging during the analysis phase";
}
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/Substitute_JmxServiceImpl.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/Substitute_JmxServiceImpl.java
deleted file mode 100644
index 3992829877d91..0000000000000
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/Substitute_JmxServiceImpl.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package io.quarkus.hibernate.orm.runtime.graal;
-
-import java.util.Map;
-
-import javax.management.ObjectName;
-
-import org.hibernate.jmx.spi.JmxService;
-import org.hibernate.service.Service;
-import org.hibernate.service.spi.Manageable;
-
-import com.oracle.svm.core.annotate.Substitute;
-import com.oracle.svm.core.annotate.TargetClass;
-
-@TargetClass(className = "org.hibernate.jmx.internal.JmxServiceImpl")
-@Substitute
-public final class Substitute_JmxServiceImpl implements JmxService {
-
- @Substitute
- @SuppressWarnings("rawtypes")
- public Substitute_JmxServiceImpl(Map configValues) {
- // ignored but needs to exist
- }
-
- @Override
- public void registerService(Manageable service, Class extends Service> serviceRole) {
- // no-op
- }
-
- @Override
- public void registerMBean(ObjectName objectName, Object mBean) {
- // no-op
- }
-}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/service/jacc/Delete_StandardJaccServiceImpl.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/service/jacc/Delete_StandardJaccServiceImpl.java
deleted file mode 100644
index ef951c76e1f24..0000000000000
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/service/jacc/Delete_StandardJaccServiceImpl.java
+++ /dev/null
@@ -1,9 +0,0 @@
-package io.quarkus.hibernate.orm.runtime.graal.service.jacc;
-
-import com.oracle.svm.core.annotate.Delete;
-import com.oracle.svm.core.annotate.TargetClass;
-
-@TargetClass(className = "org.hibernate.secure.internal.StandardJaccServiceImpl")
-@Delete
-public final class Delete_StandardJaccServiceImpl {
-}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/service/jacc/Substitute_JaccIntegrator.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/service/jacc/Substitute_JaccIntegrator.java
deleted file mode 100644
index 148d169326445..0000000000000
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/graal/service/jacc/Substitute_JaccIntegrator.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package io.quarkus.hibernate.orm.runtime.graal.service.jacc;
-
-import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
-import org.hibernate.secure.internal.DisabledJaccServiceImpl;
-import org.hibernate.secure.spi.JaccService;
-import org.jboss.logging.Logger;
-
-import com.oracle.svm.core.annotate.Alias;
-import com.oracle.svm.core.annotate.Substitute;
-import com.oracle.svm.core.annotate.TargetClass;
-
-@TargetClass(className = "org.hibernate.secure.spi.JaccIntegrator")
-public final class Substitute_JaccIntegrator {
-
- @Alias
- private static Logger log;
-
- @Substitute
- public void prepareServices(StandardServiceRegistryBuilder serviceRegistryBuilder) {
- serviceRegistryBuilder.addService(JaccService.class, new DisabledJaccServiceImpl());
- }
-}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/observers/SessionFactoryObserverForNamedQueryValidation.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/observers/SessionFactoryObserverForNamedQueryValidation.java
new file mode 100644
index 0000000000000..2ba26bd5f14c6
--- /dev/null
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/observers/SessionFactoryObserverForNamedQueryValidation.java
@@ -0,0 +1,30 @@
+package io.quarkus.hibernate.orm.runtime.observers;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.SessionFactoryObserver;
+import org.hibernate.boot.Metadata;
+import org.hibernate.boot.spi.MetadataImplementor;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.query.spi.QueryEngine;
+
+//TODO replace with vanilla SessionFactoryObserverForNamedQueryValidation ?
+//currently not possible as it was made package private;
+//even better: decouple the query validation from the SessionFactory,
+//so to allow validations at build time.
+public class SessionFactoryObserverForNamedQueryValidation implements SessionFactoryObserver {
+ private final Metadata metadata;
+
+ public SessionFactoryObserverForNamedQueryValidation(MetadataImplementor metadata) {
+ this.metadata = metadata;
+ }
+
+ @Override
+ public void sessionFactoryCreated(SessionFactory factory) {
+ SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) factory;
+ final QueryEngine queryEngine = sessionFactory.getQueryEngine();
+ queryEngine.prepare(sessionFactory, metadata);
+ if (sessionFactory.getSessionFactoryOptions().isNamedQueryStartupCheckingEnabled()) {
+ queryEngine.validateNamedQueries();
+ }
+ }
+}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/observers/SessionFactoryObserverForSchemaExport.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/observers/SessionFactoryObserverForSchemaExport.java
new file mode 100644
index 0000000000000..3e2c97f300d45
--- /dev/null
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/observers/SessionFactoryObserverForSchemaExport.java
@@ -0,0 +1,38 @@
+package io.quarkus.hibernate.orm.runtime.observers;
+
+import org.hibernate.SessionFactory;
+import org.hibernate.SessionFactoryObserver;
+import org.hibernate.boot.spi.MetadataImplementor;
+import org.hibernate.engine.spi.SessionFactoryImplementor;
+import org.hibernate.service.spi.ServiceRegistryImplementor;
+import org.hibernate.tool.schema.spi.DelayedDropAction;
+import org.hibernate.tool.schema.spi.SchemaManagementToolCoordinator;
+
+public final class SessionFactoryObserverForSchemaExport implements SessionFactoryObserver {
+ private final MetadataImplementor metadata;
+ private DelayedDropAction delayedDropAction;
+
+ public SessionFactoryObserverForSchemaExport(MetadataImplementor metadata) {
+ this.metadata = metadata;
+ }
+
+ @Override
+ public void sessionFactoryCreated(SessionFactory factory) {
+ SchemaManagementToolCoordinator.process(
+ metadata,
+ getRegistry(factory),
+ factory.getProperties(),
+ action -> delayedDropAction = action);
+ }
+
+ @Override
+ public void sessionFactoryClosing(SessionFactory factory) {
+ if (delayedDropAction != null) {
+ delayedDropAction.perform(getRegistry(factory));
+ }
+ }
+
+ private static ServiceRegistryImplementor getRegistry(SessionFactory factory) {
+ return ((SessionFactoryImplementor) factory).getServiceRegistry();
+ }
+}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java
index 7a85c3d2abe90..5d831ac08c605 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/proxies/ProxyDefinitions.java
@@ -5,7 +5,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
-import java.util.Set;
import java.util.function.Supplier;
import org.hibernate.HibernateException;
@@ -109,7 +108,8 @@ private static Class> generateProxyClass(PersistentClass persistentClass,
+ "') as it's final. Your application might perform better if we're allowed to extend it.");
return null;
}
- final Set proxyInterfaces = ProxyFactoryHelper.extractProxyInterfaces(persistentClass, entityName);
+ final java.util.Set> proxyInterfaces = org.hibernate.proxy.pojo.ProxyFactoryHelper
+ .extractProxyInterfaces(persistentClass, entityName);
PreGeneratedProxies.ProxyClassDetailsHolder preProxy = preGeneratedProxies.getProxies()
.get(persistentClass.getClassName());
Class> preGeneratedProxy = null;
@@ -155,7 +155,7 @@ private static Class> generateProxyClass(PersistentClass persistentClass,
}
}
- private static Class[] toArray(final Set interfaces) {
+ private static Class[] toArray(final java.util.Set> interfaces) {
if (interfaces == null) {
return ArrayHelper.EMPTY_CLASS_ARRAY;
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/PrevalidatedQuarkusMetadata.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/PrevalidatedQuarkusMetadata.java
index f186a1bc69fe4..d620d37d0a26a 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/PrevalidatedQuarkusMetadata.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/PrevalidatedQuarkusMetadata.java
@@ -1,9 +1,11 @@
package io.quarkus.hibernate.orm.runtime.recording;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
+import java.util.function.Consumer;
import org.hibernate.MappingException;
import org.hibernate.SessionFactory;
@@ -11,27 +13,27 @@
import org.hibernate.boot.internal.MetadataImpl;
import org.hibernate.boot.internal.SessionFactoryOptionsBuilder;
import org.hibernate.boot.model.IdentifierGeneratorDefinition;
+import org.hibernate.boot.model.NamedEntityGraphDefinition;
import org.hibernate.boot.model.TypeDefinition;
import org.hibernate.boot.model.relational.Database;
+import org.hibernate.boot.query.NamedHqlQueryDefinition;
+import org.hibernate.boot.query.NamedNativeQueryDefinition;
+import org.hibernate.boot.query.NamedProcedureCallDefinition;
+import org.hibernate.boot.query.NamedResultSetMappingDescriptor;
+import org.hibernate.boot.spi.BootstrapContext;
import org.hibernate.boot.spi.MetadataBuildingOptions;
import org.hibernate.boot.spi.MetadataImplementor;
-import org.hibernate.cfg.annotations.NamedEntityGraphDefinition;
-import org.hibernate.cfg.annotations.NamedProcedureCallDefinition;
-import org.hibernate.dialect.function.SQLFunction;
-import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.spi.FilterDefinition;
-import org.hibernate.engine.spi.NamedQueryDefinition;
-import org.hibernate.engine.spi.NamedSQLQueryDefinition;
import org.hibernate.engine.spi.SessionFactoryImplementor;
-import org.hibernate.id.factory.IdentifierGeneratorFactory;
-import org.hibernate.internal.SessionFactoryImpl;
+import org.hibernate.mapping.Component;
import org.hibernate.mapping.FetchProfile;
import org.hibernate.mapping.MappedSuperclass;
import org.hibernate.mapping.PersistentClass;
import org.hibernate.mapping.Table;
-import org.hibernate.query.spi.NamedQueryRepository;
+import org.hibernate.query.named.NamedObjectRepository;
+import org.hibernate.query.sqm.function.SqmFunctionDescriptor;
+import org.hibernate.query.sqm.function.SqmFunctionRegistry;
import org.hibernate.type.Type;
-import org.hibernate.type.TypeResolver;
import org.hibernate.type.spi.TypeConfiguration;
/**
@@ -68,9 +70,10 @@ public SessionFactoryOptionsBuilder buildSessionFactoryOptionsBuilder() {
metadata.getBootstrapContext());
// This would normally be done by the constructor of SessionFactoryBuilderImpl,
// but we don't use a builder to create the session factory, for some reason.
- Map sqlFunctions = metadata.getSqlFunctionMap();
+
+ Map sqlFunctions = metadata.getSqlFunctionMap();
if (sqlFunctions != null) {
- for (Map.Entry entry : sqlFunctions.entrySet()) {
+ for (Map.Entry entry : sqlFunctions.entrySet()) {
builder.applySqlFunction(entry.getKey(), entry.getValue());
}
}
@@ -134,38 +137,43 @@ public Map getImports() {
}
@Override
- public NamedQueryDefinition getNamedQueryDefinition(final String name) {
- return metadata.getNamedQueryDefinition(name);
+ public NamedHqlQueryDefinition getNamedHqlQueryMapping(String name) {
+ return metadata.getNamedHqlQueryMapping(name);
}
@Override
- public Collection getNamedQueryDefinitions() {
- return metadata.getNamedQueryDefinitions();
+ public void visitNamedHqlQueryDefinitions(Consumer definitionConsumer) {
+ metadata.visitNamedHqlQueryDefinitions(definitionConsumer);
}
@Override
- public NamedSQLQueryDefinition getNamedNativeQueryDefinition(final String name) {
- return metadata.getNamedNativeQueryDefinition(name);
+ public NamedNativeQueryDefinition getNamedNativeQueryMapping(String name) {
+ return metadata.getNamedNativeQueryMapping(name);
}
@Override
- public Collection getNamedNativeQueryDefinitions() {
- return metadata.getNamedNativeQueryDefinitions();
+ public void visitNamedNativeQueryDefinitions(Consumer definitionConsumer) {
+ metadata.visitNamedNativeQueryDefinitions(definitionConsumer);
}
@Override
- public Collection getNamedProcedureCallDefinitions() {
- return metadata.getNamedProcedureCallDefinitions();
+ public NamedProcedureCallDefinition getNamedProcedureCallMapping(String name) {
+ return metadata.getNamedProcedureCallMapping(name);
}
@Override
- public ResultSetMappingDefinition getResultSetMapping(final String name) {
+ public void visitNamedProcedureCallDefinition(Consumer definitionConsumer) {
+ metadata.visitNamedProcedureCallDefinition(definitionConsumer);
+ }
+
+ @Override
+ public NamedResultSetMappingDescriptor getResultSetMapping(String name) {
return metadata.getResultSetMapping(name);
}
@Override
- public Map getResultSetMappingDefinitions() {
- return metadata.getResultSetMappingDefinitions();
+ public void visitNamedResultSetMappingDefinition(Consumer definitionConsumer) {
+ metadata.visitNamedResultSetMappingDefinition(definitionConsumer);
}
@Override
@@ -214,18 +222,17 @@ public Collection collectTableMappings() {
}
@Override
- public Map getSqlFunctionMap() {
+ public Map getSqlFunctionMap() {
return metadata.getSqlFunctionMap();
}
- //All methods from org.hibernate.engine.spi.Mapping, the parent of Metadata:
-
@Override
- @Deprecated
- public IdentifierGeneratorFactory getIdentifierGeneratorFactory() {
- return metadata.getIdentifierGeneratorFactory();
+ public Set getContributors() {
+ return metadata.getContributors();
}
+ //All methods from org.hibernate.engine.spi.Mapping, the parent of Metadata:
+
@Override
public Type getIdentifierType(final String className) throws MappingException {
return metadata.getIdentifierType(className);
@@ -254,15 +261,20 @@ public TypeConfiguration getTypeConfiguration() {
}
@Override
- public TypeResolver getTypeResolver() {
- return metadata.getTypeResolver();
+ public SqmFunctionRegistry getFunctionRegistry() {
+ return metadata.getFunctionRegistry();
}
@Override
- public NamedQueryRepository buildNamedQueryRepository(SessionFactoryImpl sessionFactory) {
+ public NamedObjectRepository buildNamedQueryRepository(SessionFactoryImplementor sessionFactory) {
return metadata.buildNamedQueryRepository(sessionFactory);
}
+ @Override
+ public void orderColumns(boolean forceOrdering) {
+ metadata.orderColumns(forceOrdering);
+ }
+
@Override
public Set getMappedSuperclassMappingsCopy() {
return metadata.getMappedSuperclassMappingsCopy();
@@ -273,4 +285,61 @@ public void initSessionFactory(SessionFactoryImplementor sessionFactoryImplement
metadata.initSessionFactory(sessionFactoryImplementor);
}
+ @Override
+ public void visitRegisteredComponents(Consumer consumer) {
+ metadata.visitRegisteredComponents(consumer);
+ }
+
+ public Map getEntityBindingMap() {
+ return metadata.getEntityBindingMap();
+ }
+
+ public Map getCollectionBindingMap() {
+ return metadata.getCollectionBindingMap();
+ }
+
+ public Map getTypeDefinitionMap() {
+ return metadata.getTypeDefinitionMap();
+ }
+
+ public Map getFetchProfileMap() {
+ return metadata.getFetchProfileMap();
+ }
+
+ public Map, MappedSuperclass> getMappedSuperclassMap() {
+ return metadata.getMappedSuperclassMap();
+ }
+
+ public Map getIdGeneratorDefinitionMap() {
+ return metadata.getIdGeneratorDefinitionMap();
+ }
+
+ public Map getNamedEntityGraphMap() {
+ return metadata.getNamedEntityGraphMap();
+ }
+
+ public BootstrapContext getBootstrapContext() {
+ return metadata.getBootstrapContext();
+ }
+
+ public Map getNamedQueryMap() {
+ return metadata.getNamedQueryMap();
+ }
+
+ public Map getNamedNativeQueryMap() {
+ return metadata.getNamedNativeQueryMap();
+ }
+
+ public Map getNamedProcedureCallMap() {
+ return metadata.getNamedProcedureCallMap();
+ }
+
+ public Map getSqlResultSetMappingMap() {
+ return metadata.getSqlResultSetMappingMap();
+ }
+
+ public List getComposites() {
+ return metadata.getComposites();
+ }
+
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/RecordableBootstrap.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/RecordableBootstrap.java
index e7f2970f75176..589018fa48c79 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/RecordableBootstrap.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/RecordableBootstrap.java
@@ -7,6 +7,7 @@
import java.util.List;
import java.util.Map;
+import org.hibernate.boot.cfgxml.internal.ConfigLoader;
import org.hibernate.boot.cfgxml.spi.LoadedConfig;
import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.boot.registry.StandardServiceInitiator;
@@ -29,9 +30,9 @@ public final class RecordableBootstrap extends StandardServiceRegistryBuilder {
private static final String DISABLED_FEATURE_MSG = "This feature was disabled in Quarkus - this method should not have invoked, please report";
- private final Map settings;
- private final List initiators;
- private final List providedServices = new ArrayList();
+ private final Map settings;
+ private final List> initiators;
+ private final List> providedServices = new ArrayList<>();
private final List> postBuildProvidedServices = new ArrayList<>();
private boolean autoCloseRegistry = true;
@@ -41,12 +42,12 @@ public final class RecordableBootstrap extends StandardServiceRegistryBuilder {
public RecordableBootstrap(BootstrapServiceRegistry bootstrapServiceRegistry,
InitialInitiatorListProvider initialInitiatorsProvider) {
- this(bootstrapServiceRegistry, new HashMap(), LoadedConfig.baseline(), initialInitiatorsProvider);
+ this(bootstrapServiceRegistry, new HashMap(), LoadedConfig.baseline(), initialInitiatorsProvider);
}
- private RecordableBootstrap(BootstrapServiceRegistry bootstrapServiceRegistry, Map properties,
+ private RecordableBootstrap(BootstrapServiceRegistry bootstrapServiceRegistry, Map properties,
LoadedConfig loadedConfigBaseline, InitialInitiatorListProvider initialInitiatorsProvider) {
- super(bootstrapServiceRegistry, properties, loadedConfigBaseline, null);
+ super(bootstrapServiceRegistry, properties, new ConfigLoader(bootstrapServiceRegistry), loadedConfigBaseline, null);
this.settings = properties;
this.bootstrapServiceRegistry = bootstrapServiceRegistry;
this.aggregatedCfgXml = loadedConfigBaseline;
@@ -67,13 +68,11 @@ public BootstrapServiceRegistry getBootstrapServiceRegistry() {
}
@Override
- @SuppressWarnings({ "unchecked" })
public StandardServiceRegistryBuilder loadProperties(String resourceName) {
throw new UnsupportedOperationException(DISABLED_FEATURE_MSG);
}
@Override
- @SuppressWarnings({ "unchecked" })
public StandardServiceRegistryBuilder loadProperties(File file) {
throw new UnsupportedOperationException(DISABLED_FEATURE_MSG);
}
@@ -109,7 +108,6 @@ public StandardServiceRegistryBuilder configure(URL url) {
}
@Override
- @SuppressWarnings({ "unchecked" })
public StandardServiceRegistryBuilder configure(LoadedConfig loadedConfig) {
throw new UnsupportedOperationException(DISABLED_FEATURE_MSG);
}
@@ -123,7 +121,6 @@ public StandardServiceRegistryBuilder configure(LoadedConfig loadedConfig) {
* @return this, for method chaining
*/
@Override
- @SuppressWarnings({ "unchecked", "UnusedDeclaration" })
public StandardServiceRegistryBuilder applySetting(String settingName, Object value) {
settings.put(settingName, value);
return this;
@@ -137,8 +134,7 @@ public StandardServiceRegistryBuilder applySetting(String settingName, Object va
* @return this, for method chaining
*/
@Override
- @SuppressWarnings({ "unchecked", "UnusedDeclaration" })
- public StandardServiceRegistryBuilder applySettings(Map settings) {
+ public StandardServiceRegistryBuilder applySettings(Map settings) {
this.settings.putAll(settings);
return this;
}
@@ -156,8 +152,7 @@ public void clearSettings() {
* @return this, for method chaining
*/
@Override
- @SuppressWarnings({ "UnusedDeclaration" })
- public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator initiator) {
+ public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator> initiator) {
initiators.add(initiator);
postBuildProvidedServices.add(initiator.getServiceInitiated());
return this;
@@ -172,9 +167,8 @@ public StandardServiceRegistryBuilder addInitiator(StandardServiceInitiator init
* @return this, for method chaining
*/
@Override
- @SuppressWarnings({ "unchecked" })
- public StandardServiceRegistryBuilder addService(final Class serviceRole, final Service service) {
- providedServices.add(new ProvidedService(serviceRole, service));
+ public StandardServiceRegistryBuilder addService(final Class serviceRole, final T service) {
+ providedServices.add(new ProvidedService<>(serviceRole, service));
return this;
}
@@ -215,11 +209,10 @@ public StandardServiceRegistryBuilder enableAutoClose() {
* @return The StandardServiceRegistry.
*/
@Override
- @SuppressWarnings("unchecked")
public StandardServiceRegistry build() {
applyServiceContributors();
- final Map settingsCopy = new HashMap();
+ final Map settingsCopy = new HashMap<>();
settingsCopy.putAll(settings);
settingsCopy.put(org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml);
@@ -236,7 +229,7 @@ private void applyServiceContributors() {
}
}
- public List getProvidedServices() {
+ public List> getProvidedServices() {
return providedServices;
}
@@ -253,7 +246,7 @@ public List getProvidedServices() {
*/
@Override
@Deprecated
- public Map getSettings() {
+ public Map getSettings() {
return settings;
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/RecordedState.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/RecordedState.java
index cf601a6079978..3ffd78098950e 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/RecordedState.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/recording/RecordedState.java
@@ -18,7 +18,7 @@ public final class RecordedState {
private final PrevalidatedQuarkusMetadata metadata;
private final BuildTimeSettings settings;
private final Collection integrators;
- private final Collection providedServices;
+ private final Collection> providedServices;
private final IntegrationSettings integrationSettings;
private final ProxyDefinitions proxyClassDefinitions;
private final boolean isReactive;
@@ -26,7 +26,7 @@ public final class RecordedState {
public RecordedState(Dialect dialect, PrevalidatedQuarkusMetadata metadata,
BuildTimeSettings settings, Collection integrators,
- Collection providedServices, IntegrationSettings integrationSettings,
+ Collection> providedServices, IntegrationSettings integrationSettings,
ProxyDefinitions classDefinitions, Optional dataSource, boolean isReactive,
boolean fromPersistenceXml) {
this.dialect = dialect;
@@ -57,7 +57,7 @@ public Collection getIntegrators() {
return integrators;
}
- public Collection getProvidedServices() {
+ public Collection> getProvidedServices() {
return providedServices;
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/schema/SchemaManagementIntegrator.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/schema/SchemaManagementIntegrator.java
index 878feccf929e1..0fc363fd702cb 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/schema/SchemaManagementIntegrator.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/schema/SchemaManagementIntegrator.java
@@ -17,11 +17,14 @@
import org.hibernate.service.spi.SessionFactoryServiceRegistry;
import org.hibernate.tool.schema.SourceType;
import org.hibernate.tool.schema.TargetType;
+import org.hibernate.tool.schema.internal.DefaultSchemaFilter;
import org.hibernate.tool.schema.internal.exec.ScriptTargetOutputToWriter;
import org.hibernate.tool.schema.spi.CommandAcceptanceException;
+import org.hibernate.tool.schema.spi.ContributableMatcher;
import org.hibernate.tool.schema.spi.ExceptionHandler;
import org.hibernate.tool.schema.spi.ExecutionOptions;
import org.hibernate.tool.schema.spi.SchemaDropper;
+import org.hibernate.tool.schema.spi.SchemaFilter;
import org.hibernate.tool.schema.spi.SchemaManagementException;
import org.hibernate.tool.schema.spi.SchemaManagementTool;
import org.hibernate.tool.schema.spi.SchemaMigrator;
@@ -105,9 +108,11 @@ public static void recreateDatabase(String name) {
SchemaManagementTool schemaManagementTool = serviceRegistry
.getService(SchemaManagementTool.class);
SchemaDropper schemaDropper = schemaManagementTool.getSchemaDropper(executionOptions.getConfigurationValues());
- schemaDropper.doDrop(holder.metadata, executionOptions, new SimpleSourceDescriptor(), new SimpleTargetDescriptor());
+ schemaDropper.doDrop(holder.metadata, executionOptions, ContributableMatcher.ALL, new SimpleSourceDescriptor(),
+ new SimpleTargetDescriptor());
schemaManagementTool.getSchemaCreator(executionOptions.getConfigurationValues())
- .doCreation(holder.metadata, executionOptions, new SimpleSourceDescriptor(), new SimpleTargetDescriptor());
+ .doCreation(holder.metadata, executionOptions, ContributableMatcher.ALL, new SimpleSourceDescriptor(),
+ new SimpleTargetDescriptor());
}
//we still clear caches though
holder.sessionFactory.getCache().evictAll();
@@ -132,13 +137,13 @@ public static void runPostBootValidation(String name) {
SimpleExecutionOptions executionOptions = new SimpleExecutionOptions(serviceRegistry);
SchemaValidator validator = schemaManagementTool.getSchemaValidator(executionOptions.getConfigurationValues());
try {
- validator.doValidation(val.metadata, executionOptions);
+ validator.doValidation(val.metadata, executionOptions, ContributableMatcher.ALL);
} catch (SchemaManagementException e) {
log.error("Failed to validate Schema: " + e.getMessage());
SchemaMigrator migrator = schemaManagementTool.getSchemaMigrator(executionOptions.getConfigurationValues());
StringWriter writer = new StringWriter();
- migrator.doMigration(val.metadata, executionOptions, new TargetDescriptor() {
+ migrator.doMigration(val.metadata, executionOptions, ContributableMatcher.ALL, new TargetDescriptor() {
@Override
public EnumSet getTargetTypes() {
return EnumSet.of(TargetType.SCRIPT);
@@ -191,14 +196,14 @@ static class Holder {
}
private static class SimpleExecutionOptions implements ExecutionOptions {
- private final Map, ?> configurationValues;
+ private final Map configurationValues;
public SimpleExecutionOptions(ServiceRegistry serviceRegistry) {
configurationValues = serviceRegistry.getService(ConfigurationService.class).getSettings();
}
@Override
- public Map, ?> getConfigurationValues() {
+ public Map getConfigurationValues() {
return configurationValues;
}
@@ -216,6 +221,11 @@ public void handleException(CommandAcceptanceException exception) {
}
};
}
+
+ @Override
+ public SchemaFilter getSchemaFilter() {
+ return DefaultSchemaFilter.INSTANCE;
+ }
}
private static class SimpleSourceDescriptor implements SourceDescriptor {
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/DisabledJMXInitiator.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/DisabledJMXInitiator.java
deleted file mode 100644
index 7e8e5b65831f7..0000000000000
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/DisabledJMXInitiator.java
+++ /dev/null
@@ -1,37 +0,0 @@
-package io.quarkus.hibernate.orm.runtime.service;
-
-import java.util.Map;
-
-import org.hibernate.boot.registry.StandardServiceInitiator;
-import org.hibernate.cfg.AvailableSettings;
-import org.hibernate.internal.util.config.ConfigurationHelper;
-import org.hibernate.jmx.internal.DisabledJmxServiceImpl;
-import org.hibernate.jmx.spi.JmxService;
-import org.hibernate.service.spi.ServiceRegistryImplementor;
-import org.jboss.logging.Logger;
-
-/**
- * Replacement implementation of org.hibernate.jmx.internal.JmxServiceInitiator
- * MBeans are currently too troublesome in GraalVM, so enforce disabling its
- * usage.
- */
-public final class DisabledJMXInitiator implements StandardServiceInitiator {
-
- public static final DisabledJMXInitiator INSTANCE = new DisabledJMXInitiator();
-
- @Override
- public Class getServiceInitiated() {
- return JmxService.class;
- }
-
- @Override
- public JmxService initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
- if (ConfigurationHelper.getBoolean(AvailableSettings.JMX_ENABLED, configurationValues, false)) {
- Logger.getLogger(DisabledJMXInitiator.class)
- .warn("Enabling JMX is not allowed in Quarkus: forcefully disabled. Ignoring property:"
- + AvailableSettings.JMX_ENABLED);
- }
- return DisabledJmxServiceImpl.INSTANCE;
- }
-
-}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/InitialInitiatorListProvider.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/InitialInitiatorListProvider.java
index 1c3924cc94f94..89d8ac7d33893 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/InitialInitiatorListProvider.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/InitialInitiatorListProvider.java
@@ -17,6 +17,6 @@
*/
public interface InitialInitiatorListProvider {
- List initialInitiatorList();
+ List> initialInitiatorList();
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusImportSqlCommandExtractorInitiator.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusImportSqlCommandExtractorInitiator.java
index 616208755b8f3..02269a2afe680 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusImportSqlCommandExtractorInitiator.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusImportSqlCommandExtractorInitiator.java
@@ -4,22 +4,22 @@
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.service.spi.ServiceRegistryImplementor;
-import org.hibernate.tool.hbm2ddl.ImportSqlCommandExtractor;
-import org.hibernate.tool.hbm2ddl.MultipleLinesSqlCommandExtractor;
+import org.hibernate.tool.schema.internal.script.MultiLineSqlScriptExtractor;
+import org.hibernate.tool.schema.spi.SqlScriptCommandExtractor;
-public final class QuarkusImportSqlCommandExtractorInitiator implements StandardServiceInitiator {
+public final class QuarkusImportSqlCommandExtractorInitiator implements StandardServiceInitiator {
public static final QuarkusImportSqlCommandExtractorInitiator INSTANCE = new QuarkusImportSqlCommandExtractorInitiator();
- private static final MultipleLinesSqlCommandExtractor SERVICE_INSTANCE = new MultipleLinesSqlCommandExtractor();
+ private static final MultiLineSqlScriptExtractor SERVICE_INSTANCE = new MultiLineSqlScriptExtractor();
@Override
- public ImportSqlCommandExtractor initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
+ public SqlScriptCommandExtractor initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
return SERVICE_INSTANCE;
}
@Override
- public Class getServiceInitiated() {
- return ImportSqlCommandExtractor.class;
+ public Class getServiceInitiated() {
+ return SqlScriptCommandExtractor.class;
}
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutableIdentifierGeneratorFactory.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutableIdentifierGeneratorFactory.java
index 0cd4167d98f38..1e27a72fa1be8 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutableIdentifierGeneratorFactory.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutableIdentifierGeneratorFactory.java
@@ -4,12 +4,16 @@
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
+import jakarta.persistence.GenerationType;
+
import org.hibernate.dialect.Dialect;
+import org.hibernate.generator.Generator;
import org.hibernate.id.IdentifierGenerator;
-import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
-import org.hibernate.service.spi.ServiceRegistryAwareService;
-import org.hibernate.service.spi.ServiceRegistryImplementor;
+import org.hibernate.id.factory.IdentifierGeneratorFactory;
+import org.hibernate.id.factory.spi.GeneratorDefinitionResolver;
+import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.Type;
+import org.hibernate.type.descriptor.java.JavaType;
/**
* Wraps the default DefaultIdentifierGeneratorFactory so to make sure we store the Class references
@@ -24,15 +28,13 @@
* just watching for these will provide the full list of Class instances we need to keep.
*/
public final class QuarkusMutableIdentifierGeneratorFactory
- implements MutableIdentifierGeneratorFactory, Serializable, ServiceRegistryAwareService {
+ implements IdentifierGeneratorFactory, Serializable {
- private final QuarkusSimplifiedIdentifierGeneratorFactory original = new QuarkusSimplifiedIdentifierGeneratorFactory();
- private final ConcurrentHashMap> typeCache = new ConcurrentHashMap<>();
+ private final QuarkusSimplifiedIdentifierGeneratorFactory original;
+ private final ConcurrentHashMap> typeCache = new ConcurrentHashMap<>();
- @Override
- public void register(final String strategy, final Class generatorClass) {
- original.register(strategy, generatorClass);
- storeCache(strategy, generatorClass);
+ public QuarkusMutableIdentifierGeneratorFactory(ServiceRegistry serviceRegistry) {
+ this.original = new QuarkusSimplifiedIdentifierGeneratorFactory(serviceRegistry);
}
@Override
@@ -41,19 +43,13 @@ public Dialect getDialect() {
}
@Override
- public void setDialect(final Dialect dialect) {
- //currently a no-op anyway..?
- original.setDialect(dialect);
- }
-
- @Override
- public IdentifierGenerator createIdentifierGenerator(final String strategy, final Type type, final Properties config) {
- final IdentifierGenerator identifierGenerator = original.createIdentifierGenerator(strategy, type, config);
+ public Generator createIdentifierGenerator(final String strategy, final Type type, final Properties config) {
+ final Generator identifierGenerator = original.createIdentifierGenerator(strategy, type, config);
storeCache(strategy, identifierGenerator.getClass());
return identifierGenerator;
}
- private void storeCache(final String strategy, final Class extends IdentifierGenerator> generatorClass) {
+ private void storeCache(final String strategy, final Class extends Generator> generatorClass) {
if (strategy == null || generatorClass == null)
return;
final String className = generatorClass.getName();
@@ -64,9 +60,14 @@ private void storeCache(final String strategy, final Class extends IdentifierG
}
}
+ public void register(String strategy, Class generatorClass) {
+ storeCache(strategy, generatorClass);
+ original.register(strategy, generatorClass);
+ }
+
@Override
public Class getIdentifierGeneratorClass(final String strategy) {
- Class extends IdentifierGenerator> aClass = typeCache.get(strategy);
+ Class extends Generator> aClass = typeCache.get(strategy);
if (aClass != null)
return aClass;
aClass = original.getIdentifierGeneratorClass(strategy);
@@ -75,7 +76,11 @@ public Class getIdentifierGeneratorClass(final String strategy) {
}
@Override
- public void injectServices(final ServiceRegistryImplementor serviceRegistry) {
- original.injectServices(serviceRegistry);
+ public IdentifierGenerator createIdentifierGenerator(GenerationType generationType,
+ String generatedValueGeneratorName, String generatorName, JavaType> javaType, Properties config,
+ GeneratorDefinitionResolver definitionResolver) {
+ return original.createIdentifierGenerator(generationType, generatedValueGeneratorName, generatorName, javaType, config,
+ definitionResolver);
}
+
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutableIdentifierGeneratorFactoryInitiator.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutableIdentifierGeneratorFactoryInitiator.java
index 63f63e84783cb..0a9c5a4d4e0a4 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutableIdentifierGeneratorFactoryInitiator.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutableIdentifierGeneratorFactoryInitiator.java
@@ -3,31 +3,28 @@
import java.util.Map;
import org.hibernate.boot.registry.StandardServiceInitiator;
-import org.hibernate.id.factory.internal.MutableIdentifierGeneratorFactoryInitiator;
-import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
+import org.hibernate.id.factory.IdentifierGeneratorFactory;
import org.hibernate.service.spi.ServiceRegistryImplementor;
/**
- * Needs to mimic MutableIdentifierGeneratorFactoryInitiator, but allows us to capture
- * which Identifier strategies are being used, so that we can keep a reference to the classed
+ * We need to mimic the standard IdentifierGeneratorFactory but allowing
+ * to capture which Identifier strategies are being used, so that we can keep a reference to the classed
* needed at runtime.
*
- * @see MutableIdentifierGeneratorFactoryInitiator
+ * @see IdentifierGeneratorFactory
*/
public final class QuarkusMutableIdentifierGeneratorFactoryInitiator
- implements StandardServiceInitiator {
-
- private final MutableIdentifierGeneratorFactory sfScopedSingleton = new QuarkusMutableIdentifierGeneratorFactory();
+ implements StandardServiceInitiator {
@Override
- public MutableIdentifierGeneratorFactory initiateService(final Map configurationValues,
+ public IdentifierGeneratorFactory initiateService(final Map configurationValues,
final ServiceRegistryImplementor registry) {
- return sfScopedSingleton;
+ return new QuarkusMutableIdentifierGeneratorFactory(registry);
}
@Override
- public Class getServiceInitiated() {
- return MutableIdentifierGeneratorFactory.class;
+ public Class getServiceInitiated() {
+ return IdentifierGeneratorFactory.class;
}
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutationExecutorServiceInitiator.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutationExecutorServiceInitiator.java
new file mode 100644
index 0000000000000..1e8d1cb0cfcaf
--- /dev/null
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusMutationExecutorServiceInitiator.java
@@ -0,0 +1,27 @@
+package io.quarkus.hibernate.orm.runtime.service;
+
+import java.util.Map;
+
+import org.hibernate.boot.registry.StandardServiceInitiator;
+import org.hibernate.engine.jdbc.mutation.internal.StandardMutationExecutorService;
+import org.hibernate.engine.jdbc.mutation.spi.MutationExecutorService;
+import org.hibernate.service.spi.ServiceRegistryImplementor;
+
+public final class QuarkusMutationExecutorServiceInitiator implements StandardServiceInitiator {
+ /**
+ * Singleton access
+ */
+ public static final QuarkusMutationExecutorServiceInitiator INSTANCE = new QuarkusMutationExecutorServiceInitiator();
+
+ @Override
+ public Class getServiceInitiated() {
+ return MutationExecutorService.class;
+ }
+
+ @Override
+ public MutationExecutorService initiateService(Map configurationValues,
+ ServiceRegistryImplementor registry) {
+ return new StandardMutationExecutorService(configurationValues);
+ }
+
+}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusSimplifiedIdentifierGeneratorFactory.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusSimplifiedIdentifierGeneratorFactory.java
index 12c1ac44f1b00..3bf480af1a2cb 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusSimplifiedIdentifierGeneratorFactory.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/QuarkusSimplifiedIdentifierGeneratorFactory.java
@@ -1,13 +1,22 @@
package io.quarkus.hibernate.orm.runtime.service;
+import static org.hibernate.cfg.AvailableSettings.IDENTIFIER_GENERATOR_STRATEGY_PROVIDER;
+import static org.hibernate.id.factory.IdGenFactoryLogging.ID_GEN_FAC_LOGGER;
+
+import java.util.Map;
import java.util.Properties;
import java.util.concurrent.ConcurrentHashMap;
+import jakarta.persistence.GenerationType;
+
import org.hibernate.MappingException;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
+import org.hibernate.boot.registry.selector.spi.StrategySelector;
import org.hibernate.dialect.Dialect;
+import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.jdbc.env.spi.JdbcEnvironment;
+import org.hibernate.generator.Generator;
import org.hibernate.id.Assigned;
import org.hibernate.id.Configurable;
import org.hibernate.id.ForeignGenerator;
@@ -16,95 +25,175 @@
import org.hibernate.id.IdentityGenerator;
import org.hibernate.id.IncrementGenerator;
import org.hibernate.id.SelectGenerator;
-import org.hibernate.id.SequenceHiLoGenerator;
-import org.hibernate.id.SequenceIdentityGenerator;
import org.hibernate.id.UUIDGenerator;
import org.hibernate.id.UUIDHexGenerator;
import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.id.enhanced.TableGenerator;
-import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
-import org.hibernate.internal.CoreLogging;
-import org.hibernate.internal.CoreMessageLogger;
+import org.hibernate.id.factory.IdentifierGeneratorFactory;
+import org.hibernate.id.factory.internal.AutoGenerationTypeStrategy;
+import org.hibernate.id.factory.internal.IdentityGenerationTypeStrategy;
+import org.hibernate.id.factory.internal.SequenceGenerationTypeStrategy;
+import org.hibernate.id.factory.internal.TableGenerationTypeStrategy;
+import org.hibernate.id.factory.internal.UUIDGenerationTypeStrategy;
+import org.hibernate.id.factory.spi.GenerationTypeStrategy;
+import org.hibernate.id.factory.spi.GenerationTypeStrategyRegistration;
+import org.hibernate.id.factory.spi.GeneratorDefinitionResolver;
+import org.hibernate.internal.log.DeprecationLogger;
+import org.hibernate.jpa.spi.IdentifierGeneratorStrategyProvider;
import org.hibernate.service.ServiceRegistry;
-import org.hibernate.service.spi.ServiceRegistryAwareService;
-import org.hibernate.service.spi.ServiceRegistryImplementor;
import org.hibernate.type.Type;
+import org.hibernate.type.descriptor.java.JavaType;
/**
- * Quarkus custom implementation of Hibernate ORM's org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory
+ * Quarkus custom implementation of Hibernate ORM's org.hibernate.id.factory.internal.StandardIdentifierGeneratorFactory
* differences with the original:
* 1# it does not attempt to use a BeanContainer to create instances; Hibernate ORM introduced this feature in HHH-14688
- * 2# No need to handle AvailableSettings.USE_NEW_ID_GENERATOR_MAPPINGS as Quarkus users shouldn't disable it (on by default)
+ * 2# The register method is made public
+ * //TODO refactor ORM upstream so to allow code reuse
*/
final class QuarkusSimplifiedIdentifierGeneratorFactory
- implements MutableIdentifierGeneratorFactory, ServiceRegistryAwareService {
+ implements IdentifierGeneratorFactory {
- private static final CoreMessageLogger LOG = CoreLogging.messageLogger(QuarkusSimplifiedIdentifierGeneratorFactory.class);
+ private final ServiceRegistry serviceRegistry;
+ private final ConcurrentHashMap generatorTypeStrategyMap = new ConcurrentHashMap<>();
+ private final ConcurrentHashMap> legacyGeneratorClassNameMap = new ConcurrentHashMap<>();
- private ServiceRegistry serviceRegistry;
private Dialect dialect;
- private ConcurrentHashMap generatorStrategyToClassNameMap = new ConcurrentHashMap<>();
+ public QuarkusSimplifiedIdentifierGeneratorFactory(ServiceRegistry serviceRegistry) {
+ this.serviceRegistry = serviceRegistry;
+ registerJpaGenerators();
+ logOverrides();
+ registerPredefinedGenerators();
+ registerUsingLegacyContributor();
+ }
- public QuarkusSimplifiedIdentifierGeneratorFactory() {
+ //Same-as-upstream
+ private void registerJpaGenerators() {
+ generatorTypeStrategyMap.put(GenerationType.AUTO, AutoGenerationTypeStrategy.INSTANCE);
+ generatorTypeStrategyMap.put(GenerationType.SEQUENCE, SequenceGenerationTypeStrategy.INSTANCE);
+ generatorTypeStrategyMap.put(GenerationType.TABLE, TableGenerationTypeStrategy.INSTANCE);
+ generatorTypeStrategyMap.put(GenerationType.IDENTITY, IdentityGenerationTypeStrategy.INSTANCE);
+ generatorTypeStrategyMap.put(GenerationType.UUID, UUIDGenerationTypeStrategy.INSTANCE);
+ }
+
+ private void logOverrides() {
+ serviceRegistry.getService(ClassLoaderService.class)
+ .loadJavaServices(GenerationTypeStrategyRegistration.class)
+ .forEach((registration) -> registration.registerStrategies(
+ (generationType, generationTypeStrategy) -> {
+ final GenerationTypeStrategy previous = generatorTypeStrategyMap.put(generationType,
+ generationTypeStrategy);
+ if (previous != null) {
+ ID_GEN_FAC_LOGGER.debugf(
+ "GenerationTypeStrategyRegistration [%s] overrode previous registration for GenerationType#%s : %s",
+ registration,
+ generationType.name(),
+ previous);
+ }
+ },
+ serviceRegistry));
+ }
+
+ //Same-as-upstream
+ private void registerPredefinedGenerators() {
register("uuid2", UUIDGenerator.class);
+ // can be done with UuidGenerator + strategy
register("guid", GUIDGenerator.class);
- register("uuid", UUIDHexGenerator.class);
- register("uuid.hex", UUIDHexGenerator.class);
+ register("uuid", UUIDHexGenerator.class); // "deprecated" for new use
+ register("uuid.hex", UUIDHexGenerator.class); // uuid.hex is deprecated
register("assigned", Assigned.class);
register("identity", IdentityGenerator.class);
register("select", SelectGenerator.class);
register("sequence", SequenceStyleGenerator.class);
- register("seqhilo", SequenceHiLoGenerator.class);
register("increment", IncrementGenerator.class);
register("foreign", ForeignGenerator.class);
- register("sequence-identity", SequenceIdentityGenerator.class);
register("enhanced-sequence", SequenceStyleGenerator.class);
register("enhanced-table", TableGenerator.class);
}
+ //Same-as-upstream
+ private void registerUsingLegacyContributor() {
+ final ConfigurationService configService = serviceRegistry.getService(ConfigurationService.class);
+ final Object providerSetting = configService.getSettings().get(IDENTIFIER_GENERATOR_STRATEGY_PROVIDER);
+ if (providerSetting != null) {
+ DeprecationLogger.DEPRECATION_LOGGER.deprecatedSetting2(
+ IDENTIFIER_GENERATOR_STRATEGY_PROVIDER,
+ "supply a org.hibernate.id.factory.spi.GenerationTypeStrategyRegistration Java service");
+ final IdentifierGeneratorStrategyProvider idGeneratorStrategyProvider = serviceRegistry
+ .getService(StrategySelector.class)
+ .resolveStrategy(IdentifierGeneratorStrategyProvider.class, providerSetting);
+ for (Map.Entry> entry : idGeneratorStrategyProvider.getStrategies().entrySet()) {
+ @SuppressWarnings({ "rawtypes", "unchecked" })
+ Class extends IdentifierGenerator> generatorClass = (Class) entry.getValue();
+ register(entry.getKey(), generatorClass);
+ }
+ }
+ }
+
+ //Same-as-upstream - but made public
public void register(String strategy, Class generatorClass) {
- LOG.debugf("Registering IdentifierGenerator strategy [%s] -> [%s]", strategy, generatorClass.getName());
- final Class previous = generatorStrategyToClassNameMap.put(strategy, generatorClass);
- if (previous != null) {
- LOG.debugf(" - overriding [%s]", previous.getName());
+ ID_GEN_FAC_LOGGER.debugf("Registering IdentifierGenerator strategy [%s] -> [%s]", strategy, generatorClass.getName());
+ final Class> previous = legacyGeneratorClassNameMap.put(strategy, generatorClass);
+ if (previous != null && ID_GEN_FAC_LOGGER.isDebugEnabled()) {
+ ID_GEN_FAC_LOGGER.debugf(" - overriding [%s]", previous.getName());
}
}
- @Override
- public Dialect getDialect() {
- return dialect;
+ @Override //Same-as-upstream
+ public IdentifierGenerator createIdentifierGenerator(
+ GenerationType generationType,
+ String generatedValueGeneratorName,
+ String generatorName,
+ JavaType> javaType,
+ Properties config,
+ GeneratorDefinitionResolver definitionResolver) {
+ final GenerationTypeStrategy strategy = generatorTypeStrategyMap.get(generationType);
+ if (strategy != null) {
+ return strategy.createIdentifierGenerator(
+ generationType,
+ generatorName,
+ javaType,
+ config,
+ definitionResolver,
+ serviceRegistry);
+ }
+ throw new UnsupportedOperationException("No GenerationTypeStrategy specified");
}
- @Override
- public void setDialect(Dialect dialect) {
- //This is all commented out in the original code in Hibernate ORM as well
+ @Override //Same-as-upstream
+ public Dialect getDialect() {
+ if (dialect == null) {
+ dialect = serviceRegistry.getService(JdbcEnvironment.class).getDialect();
+ }
+ return dialect;
}
+ //Different than upstream: ignore all complexity related to it having generators
+ //managed by a bean container.
@Override
- public IdentifierGenerator createIdentifierGenerator(String strategy, Type type, Properties config) {
+ public Generator createIdentifierGenerator(String strategy, Type type, Properties parameters) {
+ final Class extends Generator> clazz = getIdentifierGeneratorClass(strategy);
try {
- Class clazz = getIdentifierGeneratorClass(strategy);
- IdentifierGenerator identifierGenerator = (IdentifierGenerator) clazz.getDeclaredConstructor()
- .newInstance();
+ final Generator identifierGenerator = clazz.getConstructor().newInstance();
if (identifierGenerator instanceof Configurable) {
- ((Configurable) identifierGenerator).configure(type, config, serviceRegistry);
+ ((Configurable) identifierGenerator).configure(type, parameters, serviceRegistry);
}
return identifierGenerator;
} catch (Exception e) {
- final String entityName = config.getProperty(IdentifierGenerator.ENTITY_NAME);
- throw new MappingException("Could not instantiate id generator [entity-name=" + entityName + "]", e);
+ final String entityName = parameters.getProperty(IdentifierGenerator.ENTITY_NAME);
+ throw new MappingException("Could not instantiate id generator [entity-name=" + entityName + "]");
}
}
- @Override
+ @Override //Same-as-upstream
public Class getIdentifierGeneratorClass(String strategy) {
if ("hilo".equals(strategy)) {
throw new UnsupportedOperationException("Support for 'hilo' generator has been removed");
}
String resolvedStrategy = "native".equals(strategy) ? getDialect().getNativeIdentifierGeneratorStrategy() : strategy;
- Class generatorClass = generatorStrategyToClassNameMap.get(resolvedStrategy);
+ Class generatorClass = legacyGeneratorClassNameMap.get(resolvedStrategy);
try {
if (generatorClass == null) {
final ClassLoaderService cls = serviceRegistry.getService(ClassLoaderService.class);
@@ -116,10 +205,4 @@ public Class getIdentifierGeneratorClass(String strategy) {
return generatorClass;
}
- @Override
- public void injectServices(ServiceRegistryImplementor serviceRegistry) {
- this.serviceRegistry = serviceRegistry;
- this.dialect = serviceRegistry.getService(JdbcEnvironment.class).getDialect();
- }
-
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/StandardHibernateORMInitiatorListProvider.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/StandardHibernateORMInitiatorListProvider.java
index a44751211b5e4..b8a4283889c55 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/StandardHibernateORMInitiatorListProvider.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/StandardHibernateORMInitiatorListProvider.java
@@ -6,14 +6,13 @@
import org.hibernate.boot.cfgxml.internal.CfgXmlAccessServiceInitiator;
import org.hibernate.boot.registry.StandardServiceInitiator;
import org.hibernate.engine.config.internal.ConfigurationServiceInitiator;
-import org.hibernate.engine.jdbc.batch.internal.UnmodifiableBatchBuilderInitiator;
+import org.hibernate.engine.jdbc.batch.internal.BatchBuilderInitiator;
import org.hibernate.engine.jdbc.connections.internal.MultiTenantConnectionProviderInitiator;
import org.hibernate.engine.jdbc.cursor.internal.RefCursorSupportInitiator;
import org.hibernate.engine.jdbc.dialect.internal.DialectResolverInitiator;
import org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator;
import org.hibernate.engine.jdbc.internal.JdbcServicesInitiator;
import org.hibernate.event.internal.EntityCopyObserverFactoryInitiator;
-import org.hibernate.hql.internal.QueryTranslatorFactoryInitiator;
import org.hibernate.persister.internal.PersisterClassResolverInitiator;
import org.hibernate.persister.internal.PersisterFactoryInitiator;
import org.hibernate.property.access.internal.PropertyAccessStrategyResolverInitiator;
@@ -37,13 +36,13 @@
public final class StandardHibernateORMInitiatorListProvider implements InitialInitiatorListProvider {
@Override
- public List initialInitiatorList() {
+ public List> initialInitiatorList() {
// Note to maintainers: always remember to check for consistency needs with both:
// io.quarkus.hibernate.orm.runtime.boot.registry.PreconfiguredServiceRegistryBuilder#buildQuarkusServiceInitiatorList(RecordedState)
// and ReactiveHibernateInitiatorListProvider
- final ArrayList serviceInitiators = new ArrayList();
+ final ArrayList> serviceInitiators = new ArrayList<>();
//This one needs to be replaced after Metadata has been recorded:
serviceInitiators.add(BootstrapOnlyProxyFactoryFactoryInitiator.INSTANCE);
@@ -62,9 +61,6 @@ public List initialInitiatorList() {
// Custom one!
serviceInitiators.add(QuarkusJndiServiceInitiator.INSTANCE);
- // Custom one!
- serviceInitiators.add(DisabledJMXInitiator.INSTANCE);
-
serviceInitiators.add(PersisterClassResolverInitiator.INSTANCE);
serviceInitiators.add(PersisterFactoryInitiator.INSTANCE);
@@ -76,13 +72,10 @@ public List initialInitiatorList() {
// Custom one!
serviceInitiators.add(DialectFactoryInitiator.INSTANCE);
- // Non-default implementation: optimised for lack of JMX management
- serviceInitiators.add(UnmodifiableBatchBuilderInitiator.INSTANCE);
+ serviceInitiators.add(BatchBuilderInitiator.INSTANCE);
serviceInitiators.add(JdbcServicesInitiator.INSTANCE);
serviceInitiators.add(RefCursorSupportInitiator.INSTANCE);
- serviceInitiators.add(QueryTranslatorFactoryInitiator.INSTANCE);
-
// Custom one! Also, this one has state so can't use the singleton.
serviceInitiators.add(new QuarkusMutableIdentifierGeneratorFactoryInitiator());// MutableIdentifierGeneratorFactoryInitiator.INSTANCE);
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/bytecodeprovider/QuarkusRuntimeBytecodeProviderInitiator.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/bytecodeprovider/QuarkusRuntimeBytecodeProviderInitiator.java
new file mode 100644
index 0000000000000..0b164364d7e41
--- /dev/null
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/bytecodeprovider/QuarkusRuntimeBytecodeProviderInitiator.java
@@ -0,0 +1,32 @@
+package io.quarkus.hibernate.orm.runtime.service.bytecodeprovider;
+
+import java.util.Map;
+
+import org.hibernate.boot.registry.StandardServiceInitiator;
+import org.hibernate.bytecode.spi.BytecodeProvider;
+import org.hibernate.service.spi.ServiceRegistryImplementor;
+
+import io.quarkus.hibernate.orm.runtime.customized.QuarkusRuntimeProxyFactoryFactory;
+
+public final class QuarkusRuntimeBytecodeProviderInitiator implements StandardServiceInitiator {
+
+ private final QuarkusRuntimeProxyFactoryFactory statefulProxyFactory;
+
+ public QuarkusRuntimeBytecodeProviderInitiator(QuarkusRuntimeProxyFactoryFactory statefulProxyFactory) {
+ this.statefulProxyFactory = statefulProxyFactory;
+ }
+
+ @Override
+ public BytecodeProvider initiateService(Map configurationValues, ServiceRegistryImplementor registry) {
+ //This one disables any use of bytecode enhancement at runtime, but is slightly more lenient
+ //than the "none" option which will throw an exception on any attempt of using it;
+ //also, needs to carry the statefulProxyFactory.
+ return new RuntimeBytecodeProvider(statefulProxyFactory);
+ }
+
+ @Override
+ public Class getServiceInitiated() {
+ return BytecodeProvider.class;
+ }
+
+}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/bytecodeprovider/RuntimeBytecodeProvider.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/bytecodeprovider/RuntimeBytecodeProvider.java
new file mode 100644
index 0000000000000..cde9b0b109318
--- /dev/null
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/service/bytecodeprovider/RuntimeBytecodeProvider.java
@@ -0,0 +1,45 @@
+package io.quarkus.hibernate.orm.runtime.service.bytecodeprovider;
+
+import java.util.Map;
+
+import org.hibernate.bytecode.enhance.spi.EnhancementContext;
+import org.hibernate.bytecode.enhance.spi.Enhancer;
+import org.hibernate.bytecode.spi.BytecodeProvider;
+import org.hibernate.bytecode.spi.ProxyFactoryFactory;
+import org.hibernate.bytecode.spi.ReflectionOptimizer;
+import org.hibernate.property.access.spi.PropertyAccess;
+
+import io.quarkus.hibernate.orm.runtime.customized.QuarkusRuntimeProxyFactoryFactory;
+
+final class RuntimeBytecodeProvider implements BytecodeProvider {
+
+ private final QuarkusRuntimeProxyFactoryFactory statefulProxyFactory;
+
+ public RuntimeBytecodeProvider(QuarkusRuntimeProxyFactoryFactory statefulProxyFactory) {
+ this.statefulProxyFactory = statefulProxyFactory;
+ }
+
+ @Override
+ public ProxyFactoryFactory getProxyFactoryFactory() {
+ return statefulProxyFactory;
+ }
+
+ @Override
+ public ReflectionOptimizer getReflectionOptimizer(
+ Class clazz,
+ String[] getterNames,
+ String[] setterNames,
+ Class[] types) {
+ return null;
+ }
+
+ @Override
+ public ReflectionOptimizer getReflectionOptimizer(Class> clazz, Map propertyAccessMap) {
+ return null;
+ }
+
+ @Override
+ public Enhancer getEnhancer(EnhancementContext enhancementContext) {
+ return null;
+ }
+}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/session/JTASessionOpener.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/session/JTASessionOpener.java
index a9e22a266849e..581e6842b481d 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/session/JTASessionOpener.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/session/JTASessionOpener.java
@@ -27,7 +27,7 @@ public static JTASessionOpener create(SessionFactory sessionFactory) {
}
}
- private static SessionBuilder> createOptions(SessionFactory sessionFactory) {
+ private static SessionBuilder createOptions(SessionFactory sessionFactory) {
return sessionFactory.withOptions()
.autoClose(true) // .owner() is deprecated as well, so it looks like we need to rely on deprecated code...
.connectionHandlingMode(
@@ -36,15 +36,15 @@ private static SessionBuilder> createOptions(SessionFactory sessionFactory) {
}
private final SessionFactory sessionFactory;
- private final SessionBuilder> cachedOptions;
+ private final SessionBuilder cachedOptions;
- public JTASessionOpener(SessionFactory sessionFactory, SessionBuilder> cachedOptions) {
+ public JTASessionOpener(SessionFactory sessionFactory, SessionBuilder cachedOptions) {
this.sessionFactory = sessionFactory;
this.cachedOptions = cachedOptions;
}
public Session openSession() {
- SessionBuilder> options = cachedOptions != null ? cachedOptions : createOptions(sessionFactory);
+ SessionBuilder options = cachedOptions != null ? cachedOptions : createOptions(sessionFactory);
return options.openSession();
}
}
diff --git a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/session/TransactionScopedSession.java b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/session/TransactionScopedSession.java
index 4bc638be51d37..93155248f8f71 100644
--- a/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/session/TransactionScopedSession.java
+++ b/extensions/hibernate-orm/runtime/src/main/java/io/quarkus/hibernate/orm/runtime/session/TransactionScopedSession.java
@@ -1,19 +1,17 @@
package io.quarkus.hibernate.orm.runtime.session;
-import java.io.Serializable;
-import java.sql.Connection;
import java.util.List;
import java.util.Map;
import jakarta.enterprise.context.ContextNotActiveException;
import jakarta.enterprise.inject.Instance;
+import jakarta.persistence.CacheRetrieveMode;
+import jakarta.persistence.CacheStoreMode;
import jakarta.persistence.EntityGraph;
import jakarta.persistence.EntityManagerFactory;
import jakarta.persistence.FlushModeType;
import jakarta.persistence.LockModeType;
-import jakarta.persistence.StoredProcedureQuery;
import jakarta.persistence.TransactionRequiredException;
-import jakarta.persistence.criteria.CriteriaBuilder;
import jakarta.persistence.criteria.CriteriaDelete;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.CriteriaUpdate;
@@ -23,7 +21,6 @@
import jakarta.transaction.TransactionSynchronizationRegistry;
import org.hibernate.CacheMode;
-import org.hibernate.Criteria;
import org.hibernate.Filter;
import org.hibernate.FlushMode;
import org.hibernate.HibernateException;
@@ -33,6 +30,7 @@
import org.hibernate.LockOptions;
import org.hibernate.MultiIdentifierLoadAccess;
import org.hibernate.NaturalIdLoadAccess;
+import org.hibernate.NaturalIdMultiLoadAccess;
import org.hibernate.ReplicationMode;
import org.hibernate.Session;
import org.hibernate.SessionEventListener;
@@ -40,14 +38,17 @@
import org.hibernate.SharedSessionBuilder;
import org.hibernate.SimpleNaturalIdLoadAccess;
import org.hibernate.Transaction;
-import org.hibernate.TypeHelper;
import org.hibernate.UnknownProfileException;
import org.hibernate.graph.RootGraph;
import org.hibernate.jdbc.ReturningWork;
import org.hibernate.jdbc.Work;
import org.hibernate.procedure.ProcedureCall;
+import org.hibernate.query.MutationQuery;
import org.hibernate.query.NativeQuery;
import org.hibernate.query.Query;
+import org.hibernate.query.SelectionQuery;
+import org.hibernate.query.criteria.HibernateCriteriaBuilder;
+import org.hibernate.query.criteria.JpaCriteriaInsertSelect;
import org.hibernate.stat.SessionStatistics;
import io.quarkus.arc.Arc;
@@ -146,7 +147,7 @@ public void persist(Object entity) {
}
@Override
- public Object merge(Object entity) {
+ public T merge(T entity) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
if (!emr.allowModification) {
@@ -207,6 +208,14 @@ public T getReference(Class entityClass, Object primaryKey) {
}
}
+ @Override
+ public Object getReference(String entityName, Object id) {
+ checkBlocking();
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.getReference(entityName, id);
+ }
+ }
+
@Override
public T getReference(T object) {
checkBlocking();
@@ -349,6 +358,7 @@ public Map getProperties() {
}
}
+ @Deprecated
@Override
public Query createQuery(String qlString) {
checkBlocking();
@@ -366,6 +376,7 @@ public Query createQuery(CriteriaQuery criteriaQuery) {
}
}
+ @Deprecated
@Override
public Query createQuery(CriteriaUpdate updateQuery) {
checkBlocking();
@@ -374,6 +385,7 @@ public Query createQuery(CriteriaUpdate updateQuery) {
}
}
+ @Deprecated
@Override
public Query createQuery(CriteriaDelete deleteQuery) {
checkBlocking();
@@ -390,6 +402,7 @@ public Query createQuery(String qlString, Class resultClass) {
}
}
+ @Deprecated
@Override
public Query createNamedQuery(String name) {
checkBlocking();
@@ -406,6 +419,7 @@ public Query createNamedQuery(String name, Class resultClass) {
}
}
+ @Deprecated
@Override
public NativeQuery createNativeQuery(String sqlString) {
checkBlocking();
@@ -414,6 +428,7 @@ public NativeQuery createNativeQuery(String sqlString) {
}
}
+ @Deprecated
@Override
public NativeQuery createNativeQuery(String sqlString, Class resultClass) {
checkBlocking();
@@ -422,6 +437,7 @@ public NativeQuery createNativeQuery(String sqlString, Class resultClass) {
}
}
+ @Deprecated
@Override
public NativeQuery createNativeQuery(String sqlString, String resultSetMapping) {
checkBlocking();
@@ -431,7 +447,7 @@ public NativeQuery createNativeQuery(String sqlString, String resultSetMapping)
}
@Override
- public StoredProcedureQuery createNamedStoredProcedureQuery(String name) {
+ public ProcedureCall createNamedStoredProcedureQuery(String name) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.createNamedStoredProcedureQuery(name);
@@ -439,7 +455,7 @@ public StoredProcedureQuery createNamedStoredProcedureQuery(String name) {
}
@Override
- public StoredProcedureQuery createStoredProcedureQuery(String procedureName) {
+ public ProcedureCall createStoredProcedureQuery(String procedureName) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.createStoredProcedureQuery(procedureName);
@@ -447,7 +463,8 @@ public StoredProcedureQuery createStoredProcedureQuery(String procedureName) {
}
@Override
- public StoredProcedureQuery createStoredProcedureQuery(String procedureName, Class... resultClasses) {
+ public ProcedureCall createStoredProcedureQuery(String procedureName,
+ @SuppressWarnings("rawtypes") Class... resultClasses) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.createStoredProcedureQuery(procedureName, resultClasses);
@@ -455,7 +472,7 @@ public StoredProcedureQuery createStoredProcedureQuery(String procedureName, Cla
}
@Override
- public StoredProcedureQuery createStoredProcedureQuery(String procedureName, String... resultSetMappings) {
+ public ProcedureCall createStoredProcedureQuery(String procedureName, String... resultSetMappings) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.createStoredProcedureQuery(procedureName, resultSetMappings);
@@ -516,7 +533,7 @@ public EntityManagerFactory getEntityManagerFactory() {
}
@Override
- public CriteriaBuilder getCriteriaBuilder() {
+ public HibernateCriteriaBuilder getCriteriaBuilder() {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.getCriteriaBuilder();
@@ -566,14 +583,6 @@ public SharedSessionBuilder sessionWithOptions() {
}
}
- @Override
- @Deprecated
- public void setFlushMode(FlushMode flushMode) {
- try (SessionResult emr = acquireSession()) {
- emr.session.setFlushMode(flushMode);
- }
- }
-
@Override
public void setHibernateFlushMode(FlushMode flushMode) {
try (SessionResult emr = acquireSession()) {
@@ -602,6 +611,34 @@ public CacheMode getCacheMode() {
}
}
+ @Override
+ public CacheStoreMode getCacheStoreMode() {
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.getCacheStoreMode();
+ }
+ }
+
+ @Override
+ public CacheRetrieveMode getCacheRetrieveMode() {
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.getCacheRetrieveMode();
+ }
+ }
+
+ @Override
+ public void setCacheStoreMode(CacheStoreMode cacheStoreMode) {
+ try (SessionResult emr = acquireSession()) {
+ emr.session.setCacheStoreMode(cacheStoreMode);
+ }
+ }
+
+ @Override
+ public void setCacheRetrieveMode(CacheRetrieveMode cacheRetrieveMode) {
+ try (SessionResult emr = acquireSession()) {
+ emr.session.setCacheRetrieveMode(cacheRetrieveMode);
+ }
+ }
+
@Override
public SessionFactory getSessionFactory() {
return sessionFactory;
@@ -637,7 +674,7 @@ public void setDefaultReadOnly(boolean readOnly) {
}
@Override
- public Serializable getIdentifier(Object object) {
+ public Object getIdentifier(Object object) {
try (SessionResult emr = acquireSession()) {
return emr.session.getIdentifier(object);
}
@@ -657,48 +694,54 @@ public void evict(Object object) {
}
}
+ @Deprecated
@Override
- public T load(Class theClass, Serializable id, LockMode lockMode) {
+ public T load(Class theClass, Object id, LockMode lockMode) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.load(theClass, id, lockMode);
}
}
+ @Deprecated
@Override
- public T load(Class theClass, Serializable id, LockOptions lockOptions) {
+ public T load(Class theClass, Object id, LockOptions lockOptions) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.load(theClass, id, lockOptions);
}
}
+ @Deprecated
@Override
- public Object load(String entityName, Serializable id, LockMode lockMode) {
+ public Object load(String entityName, Object id, LockMode lockMode) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.load(entityName, id, lockMode);
}
}
+ @Deprecated
@Override
- public Object load(String entityName, Serializable id, LockOptions lockOptions) {
+ public Object load(String entityName, Object id, LockOptions lockOptions) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.load(entityName, id, lockOptions);
}
}
+ @Deprecated
@Override
- public T load(Class theClass, Serializable id) {
+ public T load(Class theClass, Object id) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.load(theClass, id);
}
}
+ @Deprecated
@Override
- public Object load(String entityName, Serializable id) {
+ public Object load(String entityName, Object id) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.load(entityName, id);
@@ -706,13 +749,14 @@ public Object load(String entityName, Serializable id) {
}
@Override
- public void load(Object object, Serializable id) {
+ public void load(Object object, Object id) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
emr.session.load(object, id);
}
}
+ @Deprecated
@Override
public void replicate(Object object, ReplicationMode replicationMode) {
checkBlocking();
@@ -721,6 +765,7 @@ public void replicate(Object object, ReplicationMode replicationMode) {
}
}
+ @Deprecated
@Override
public void replicate(String entityName, Object object, ReplicationMode replicationMode) {
checkBlocking();
@@ -729,22 +774,25 @@ public void replicate(String entityName, Object object, ReplicationMode replicat
}
}
+ @Deprecated
@Override
- public Serializable save(Object object) {
+ public Object save(Object object) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.save(object);
}
}
+ @Deprecated
@Override
- public Serializable save(String entityName, Object object) {
+ public Object save(String entityName, Object object) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.save(entityName, object);
}
}
+ @Deprecated
@Override
public void saveOrUpdate(Object object) {
checkBlocking();
@@ -753,6 +801,7 @@ public void saveOrUpdate(Object object) {
}
}
+ @Deprecated
@Override
public void saveOrUpdate(String entityName, Object object) {
checkBlocking();
@@ -761,6 +810,7 @@ public void saveOrUpdate(String entityName, Object object) {
}
}
+ @Deprecated
@Override
public void update(Object object) {
checkBlocking();
@@ -769,6 +819,7 @@ public void update(Object object) {
}
}
+ @Deprecated
@Override
public void update(String entityName, Object object) {
checkBlocking();
@@ -778,7 +829,7 @@ public void update(String entityName, Object object) {
}
@Override
- public Object merge(String entityName, Object object) {
+ public T merge(String entityName, T object) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.merge(entityName, object);
@@ -793,6 +844,7 @@ public void persist(String entityName, Object object) {
}
}
+ @Deprecated
@Override
public void delete(Object object) {
checkBlocking();
@@ -801,6 +853,7 @@ public void delete(Object object) {
}
}
+ @Deprecated
@Override
public void delete(String entityName, Object object) {
checkBlocking();
@@ -817,6 +870,13 @@ public void lock(Object object, LockMode lockMode) {
}
}
+ @Override
+ public void lock(Object object, LockOptions lockOptions) {
+ try (SessionResult emr = acquireSession()) {
+ emr.session.lock(object, lockOptions);
+ }
+ }
+
@Override
public void lock(String entityName, Object object, LockMode lockMode) {
checkBlocking();
@@ -833,6 +893,7 @@ public LockRequest buildLockRequest(LockOptions lockOptions) {
}
}
+ @Deprecated
@Override
public void refresh(String entityName, Object object) {
checkBlocking();
@@ -857,6 +918,7 @@ public void refresh(Object object, LockOptions lockOptions) {
}
}
+ @Deprecated
@Override
public void refresh(String entityName, Object object, LockOptions lockOptions) {
checkBlocking();
@@ -874,16 +936,7 @@ public LockMode getCurrentLockMode(Object object) {
}
@Override
- @Deprecated
- public org.hibernate.Query createFilter(Object collection, String queryString) {
- checkBlocking();
- try (SessionResult emr = acquireSession()) {
- return emr.session.createFilter(collection, queryString);
- }
- }
-
- @Override
- public T get(Class entityType, Serializable id) {
+ public T get(Class entityType, Object id) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.get(entityType, id);
@@ -891,7 +944,7 @@ public T get(Class entityType, Serializable id) {
}
@Override
- public T get(Class entityType, Serializable id, LockMode lockMode) {
+ public T get(Class entityType, Object id, LockMode lockMode) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.get(entityType, id, lockMode);
@@ -899,7 +952,7 @@ public T get(Class entityType, Serializable id, LockMode lockMode) {
}
@Override
- public T get(Class entityType, Serializable id, LockOptions lockOptions) {
+ public T get(Class entityType, Object id, LockOptions lockOptions) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.get(entityType, id, lockOptions);
@@ -907,7 +960,7 @@ public T get(Class entityType, Serializable id, LockOptions lockOptions)
}
@Override
- public Object get(String entityName, Serializable id) {
+ public Object get(String entityName, Object id) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.get(entityName, id);
@@ -915,7 +968,7 @@ public Object get(String entityName, Serializable id) {
}
@Override
- public Object get(String entityName, Serializable id, LockMode lockMode) {
+ public Object get(String entityName, Object id, LockMode lockMode) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.get(entityName, id, lockMode);
@@ -923,7 +976,7 @@ public Object get(String entityName, Serializable id, LockMode lockMode) {
}
@Override
- public Object get(String entityName, Serializable id, LockOptions lockOptions) {
+ public Object get(String entityName, Object id, LockOptions lockOptions) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.get(entityName, id, lockOptions);
@@ -938,7 +991,7 @@ public String getEntityName(Object object) {
}
@Override
- public IdentifierLoadAccess byId(String entityName) {
+ public IdentifierLoadAccess byId(String entityName) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.byId(entityName);
@@ -954,7 +1007,7 @@ public MultiIdentifierLoadAccess byMultipleIds(Class entityClass) {
}
@Override
- public MultiIdentifierLoadAccess byMultipleIds(String entityName) {
+ public MultiIdentifierLoadAccess byMultipleIds(String entityName) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.byMultipleIds(entityName);
@@ -970,7 +1023,7 @@ public IdentifierLoadAccess byId(Class entityClass) {
}
@Override
- public NaturalIdLoadAccess byNaturalId(String entityName) {
+ public NaturalIdLoadAccess byNaturalId(String entityName) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.byNaturalId(entityName);
@@ -986,7 +1039,7 @@ public NaturalIdLoadAccess byNaturalId(Class entityClass) {
}
@Override
- public SimpleNaturalIdLoadAccess bySimpleNaturalId(String entityName) {
+ public SimpleNaturalIdLoadAccess bySimpleNaturalId(String entityName) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
return emr.session.bySimpleNaturalId(entityName);
@@ -1046,22 +1099,6 @@ public void setReadOnly(Object entityOrProxy, boolean readOnly) {
}
}
- @Override
- public Connection disconnect() {
- checkBlocking();
- try (SessionResult emr = acquireSession()) {
- return emr.session.disconnect();
- }
- }
-
- @Override
- public void reconnect(Connection connection) {
- checkBlocking();
- try (SessionResult emr = acquireSession()) {
- emr.session.reconnect(connection);
- }
- }
-
@Override
public boolean isFetchProfileEnabled(String name) throws UnknownProfileException {
try (SessionResult emr = acquireSession()) {
@@ -1083,13 +1120,6 @@ public void disableFetchProfile(String name) throws UnknownProfileException {
}
}
- @Override
- public TypeHelper getTypeHelper() {
- try (SessionResult emr = acquireSession()) {
- return emr.session.getTypeHelper();
- }
- }
-
@Override
public LobHelper getLobHelper() {
checkBlocking();
@@ -1105,14 +1135,6 @@ public void addEventListeners(SessionEventListener... listeners) {
}
}
- @Override
- public NativeQuery createSQLQuery(String queryString) {
- checkBlocking();
- try (SessionResult emr = acquireSession()) {
- return emr.session.createSQLQuery(queryString);
- }
- }
-
@Override
public String getTenantIdentifier() {
try (SessionResult emr = acquireSession()) {
@@ -1136,6 +1158,7 @@ public Transaction beginTransaction() {
}
}
+ @Deprecated
@Override
public Query getNamedQuery(String queryName) {
checkBlocking();
@@ -1177,92 +1200,170 @@ public ProcedureCall createStoredProcedureCall(String procedureName, String... r
}
@Override
- @Deprecated
- public Criteria createCriteria(Class persistentClass) {
+ public Integer getJdbcBatchSize() {
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.getJdbcBatchSize();
+ }
+ }
+
+ @Override
+ public void setJdbcBatchSize(Integer jdbcBatchSize) {
+ try (SessionResult emr = acquireSession()) {
+ emr.session.setJdbcBatchSize(jdbcBatchSize);
+ }
+ }
+
+ @Override
+ public void doWork(Work work) throws HibernateException {
checkBlocking();
try (SessionResult emr = acquireSession()) {
- return emr.session.createCriteria(persistentClass);
+ emr.session.doWork(work);
}
}
@Override
+ public T doReturningWork(ReturningWork work) throws HibernateException {
+ checkBlocking();
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.doReturningWork(work);
+ }
+ }
+
@Deprecated
- public Criteria createCriteria(Class persistentClass, String alias) {
+ @Override
+ public NativeQuery getNamedNativeQuery(String name) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
- return emr.session.createCriteria(persistentClass, alias);
+ return emr.session.getNamedNativeQuery(name);
}
}
@Override
- @Deprecated
- public Criteria createCriteria(String entityName) {
+ public NativeQuery createNativeQuery(String sqlString, Class resultClass, String tableAlias) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
- return emr.session.createCriteria(entityName);
+ return emr.session.createNativeQuery(sqlString, resultClass, tableAlias);
}
}
@Override
- @Deprecated
- public Criteria createCriteria(String entityName, String alias) {
+ public NativeQuery createNativeQuery(String sqlString, String resultSetMappingName, Class resultClass) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
- return emr.session.createCriteria(entityName, alias);
+ return emr.session.createNativeQuery(sqlString, resultSetMappingName, resultClass);
}
}
@Override
- public Integer getJdbcBatchSize() {
+ public SelectionQuery> createSelectionQuery(String hqlString) {
+ checkBlocking();
try (SessionResult emr = acquireSession()) {
- return emr.session.getJdbcBatchSize();
+ return emr.session.createSelectionQuery(hqlString);
}
}
@Override
- public void setJdbcBatchSize(Integer jdbcBatchSize) {
+ public SelectionQuery createSelectionQuery(String hqlString, Class resultType) {
+ checkBlocking();
try (SessionResult emr = acquireSession()) {
- emr.session.setJdbcBatchSize(jdbcBatchSize);
+ return emr.session.createSelectionQuery(hqlString, resultType);
}
}
@Override
- public void doWork(Work work) throws HibernateException {
+ public SelectionQuery createSelectionQuery(CriteriaQuery criteria) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
- emr.session.doWork(work);
+ return emr.session.createSelectionQuery(criteria);
}
}
@Override
- public T doReturningWork(ReturningWork work) throws HibernateException {
+ public MutationQuery createMutationQuery(String hqlString) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
- return emr.session.doReturningWork(work);
+ return emr.session.createMutationQuery(hqlString);
}
}
@Override
+ public MutationQuery createMutationQuery(CriteriaUpdate updateQuery) {
+ checkBlocking();
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.createMutationQuery(updateQuery);
+ }
+ }
+
+ @Override
+ public MutationQuery createMutationQuery(CriteriaDelete deleteQuery) {
+ checkBlocking();
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.createMutationQuery(deleteQuery);
+ }
+ }
+
+ @Override
+ public MutationQuery createMutationQuery(JpaCriteriaInsertSelect insertSelect) {
+ checkBlocking();
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.createMutationQuery(insertSelect);
+ }
+ }
+
+ @Override
+ public MutationQuery createNativeMutationQuery(String sqlString) {
+ checkBlocking();
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.createNativeMutationQuery(sqlString);
+ }
+ }
+
+ @Override
+ public SelectionQuery> createNamedSelectionQuery(String name) {
+ checkBlocking();
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.createNamedSelectionQuery(name);
+ }
+ }
+
+ @Override
+ public SelectionQuery createNamedSelectionQuery(String name, Class resultType) {
+ checkBlocking();
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.createNamedSelectionQuery(name, resultType);
+ }
+ }
+
+ @Override
+ public MutationQuery createNamedMutationQuery(String name) {
+ checkBlocking();
+ try (SessionResult emr = acquireSession()) {
+ return emr.session.createNamedMutationQuery(name);
+ }
+ }
+
@Deprecated
- public org.hibernate.Query getNamedSQLQuery(String name) {
+ @Override
+ public NativeQuery getNamedNativeQuery(String name, String resultSetMapping) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
- return emr.session.getNamedSQLQuery(name);
+ return emr.session.getNamedNativeQuery(name, resultSetMapping);
}
}
@Override
- public NativeQuery getNamedNativeQuery(String name) {
+ public NaturalIdMultiLoadAccess byMultipleNaturalId(Class entityClass) {
checkBlocking();
try (SessionResult emr = acquireSession()) {
- return emr.session.getNamedNativeQuery(name);
+ return emr.session.byMultipleNaturalId(entityClass);
}
}
@Override
- public Session getSession() {
+ public NaturalIdMultiLoadAccess byMultipleNaturalId(String entityName) {
+ checkBlocking();
try (SessionResult emr = acquireSession()) {
- return emr.session.getSession();
+ return emr.session.byMultipleNaturalId(entityName);
}
}
diff --git a/extensions/hibernate-search-orm-coordination-outbox-polling/runtime/pom.xml b/extensions/hibernate-search-orm-coordination-outbox-polling/runtime/pom.xml
index b85a5bc6e7930..b88ae2c973108 100644
--- a/extensions/hibernate-search-orm-coordination-outbox-polling/runtime/pom.xml
+++ b/extensions/hibernate-search-orm-coordination-outbox-polling/runtime/pom.xml
@@ -32,7 +32,7 @@