Skip to content

Commit

Permalink
Merge pull request #31235 from Sanne/ORM6
Browse files Browse the repository at this point in the history
Upgrade to Hibernate ORM 6.2
  • Loading branch information
gsmet authored Feb 23, 2023
2 parents 9f184dc + c23c65b commit f36ae55
Show file tree
Hide file tree
Showing 130 changed files with 1,689 additions and 1,086 deletions.
34 changes: 15 additions & 19 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<jakarta.interceptor-api.version>2.1.0</jakarta.interceptor-api.version>
<jakarta.json.bind-api.version>3.0.0</jakarta.json.bind-api.version>
<jakarta.mail.version>2.0.1</jakarta.mail.version>
<jakarta.persistence-api.version>3.0.0</jakarta.persistence-api.version>
<jakarta.persistence-api.version>3.1.0</jakarta.persistence-api.version>
<jakarta.servlet-api.version>6.0.0</jakarta.servlet-api.version>
<jakarta.transaction-api.version>2.0.1</jakarta.transaction-api.version>
<jakarta.validation-api.version>3.0.2</jakarta.validation-api.version>
Expand All @@ -97,9 +97,9 @@
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-codec.version>1.15</commons-codec.version>
<classmate.version>1.5.1</classmate.version>
<hibernate-orm.version>5.6.15.Final</hibernate-orm.version> <!-- When updating, align bytebuddy.version to Hibernate needs as well (just below): -->
<hibernate-orm.version>6.2.0.CR2</hibernate-orm.version> <!-- When updating, align bytebuddy.version to Hibernate needs as well (just below): -->
<bytebuddy.version>1.12.18</bytebuddy.version> <!-- Version controlled by Hibernate ORM's needs -->
<hibernate-commons-annotations.version>5.1.2.Final</hibernate-commons-annotations.version> <!-- version controlled by Hibernate ORM -->
<hibernate-commons-annotations.version>6.0.6.Final</hibernate-commons-annotations.version> <!-- version controlled by Hibernate ORM -->
<hibernate-reactive.version>1.1.9.Final</hibernate-reactive.version>
<hibernate-validator.version>8.0.0.Final</hibernate-validator.version>
<hibernate-search.version>6.1.7.Final</hibernate-search.version>
Expand All @@ -126,7 +126,7 @@
<httpasync.version>4.1.5</httpasync.version>
<cronutils.version>9.2.0</cronutils.version>
<quartz.version>2.3.2</quartz.version>
<h2.version>2.1.214</h2.version>
<h2.version>2.1.214</h2.version> <!-- When updating, needs to be matched in io.quarkus.hibernate.orm.runtime.dialect.QuarkusH2Dialect -->
<postgresql-jdbc.version>42.5.4</postgresql-jdbc.version>
<mariadb-jdbc.version>3.1.2</mariadb-jdbc.version>
<mysql-jdbc.version>8.0.30</mysql-jdbc.version>
Expand Down Expand Up @@ -176,7 +176,7 @@
<javaparser.version>3.25.0</javaparser.version>
<okhttp.version>3.14.9</okhttp.version><!-- keep in sync with okio -->
<okio.version>1.17.2</okio.version><!-- keep in sync with okhttp -->
<hibernate-quarkus-local-cache.version>0.1.1</hibernate-quarkus-local-cache.version>
<hibernate-quarkus-local-cache.version>0.2.0</hibernate-quarkus-local-cache.version>
<flapdoodle.mongo.version>4.5.1</flapdoodle.mongo.version>
<quarkus-spring-api.version>5.2.SP7</quarkus-spring-api.version>
<quarkus-spring-data-api.version>2.1.SP2</quarkus-spring-data-api.version>
Expand Down Expand Up @@ -5366,8 +5366,8 @@
<version>${hibernate-validator.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core-jakarta</artifactId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-orm.version}</version>
<exclusions>
<exclusion>
Expand All @@ -5377,18 +5377,18 @@
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-graalvm</artifactId>
<version>${hibernate-orm.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-envers-jakarta</artifactId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-envers</artifactId>
<version>${hibernate-orm.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-jpamodelgen-jakarta</artifactId>
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-jpamodelgen</artifactId>
<version>${hibernate-orm.version}</version>
</dependency>
<dependency>
Expand All @@ -5403,7 +5403,7 @@
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>quarkus-local-cache-jakarta</artifactId>
<artifactId>quarkus-local-cache</artifactId>
<version>${hibernate-quarkus-local-cache.version}</version>
</dependency>
<dependency>
Expand All @@ -5418,18 +5418,14 @@
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm-coordination-outbox-polling-jakarta</artifactId>
<artifactId>hibernate-search-mapper-orm-coordination-outbox-polling-orm6</artifactId>
<version>${hibernate-search.version}</version>
</dependency>
<dependency>
<groupId>org.hibernate.search</groupId>
<artifactId>hibernate-search-mapper-orm-jakarta</artifactId>
<artifactId>hibernate-search-mapper-orm-orm6</artifactId>
<version>${hibernate-search.version}</version>
<exclusions>
<exclusion>
<groupId>org.jboss</groupId>
<artifactId>jandex</artifactId>
</exclusion>
<!-- the right version will come with Hibernate ORM -->
<exclusion>
<groupId>org.hibernate.common</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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";
}
}
8 changes: 4 additions & 4 deletions docs/src/main/asciidoc/hibernate-orm-panache.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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? <singleColumnName>` (and single parameter) which will expand to `update from EntityName set <singleColumnName> = ?`
- `set? <update-query>` will expand to `update from EntityName set <update-query>`
- `from EntityName ...` which will expand to `update EntityName ...`
- `set? <singleColumnName>` (and single parameter) which will expand to `update EntityName set <singleColumnName> = ?`
- `set? <update-query>` will expand to `update EntityName set <update-query>`

If your delete query does not start with `delete`, we support the following additional forms:

Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -34,17 +37,18 @@ public void registerEnversReflections(BuildProducer<ReflectiveClassBuildItem> 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)));
pu.auditStrategy.ifPresent(s -> reflectiveClass.produce(new ReflectiveClassBuildItem(true, true, s)));
}
}

@BuildStep(onlyIf = NativeOrNativeSourcesBuild.class)
NativeImageFeatureBuildItem nativeImageFeature() {
return new NativeImageFeatureBuildItem(DisableLoggingFeature.class);
}

@BuildStep
@Record(ExecutionTime.STATIC_INIT)
public void applyStaticConfig(HibernateEnversRecorder recorder, HibernateEnversBuildTimeConfig buildTimeConfig,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -23,23 +23,24 @@ 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() {
return getEnversService().getAuditStrategy();
}

public EnversService getEnversService() {
return ((((SessionImpl) em.getDelegate()).getFactory().getServiceRegistry())
return ((((SessionImplementor) em.getDelegate()).getFactory().getServiceRegistry())
.getParentServiceRegistry())
.getService(EnversService.class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Loading

0 comments on commit f36ae55

Please sign in to comment.