Skip to content

Commit

Permalink
Upgrade to Hibernate ORM 7.0.0.Beta3 / Reactive 3.0.0.Beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
yrodiere committed Dec 19, 2024
1 parent 53426a7 commit 80abb44
Show file tree
Hide file tree
Showing 29 changed files with 187 additions and 165 deletions.
8 changes: 0 additions & 8 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5349,14 +5349,6 @@
<groupId>org.hibernate.orm</groupId>
<artifactId>hibernate-core</artifactId>
<version>${hibernate-orm.version}</version>
<exclusions>
<!-- We don't want Jandex at runtime -->
<!-- ... but right now we need it: https://github.com/hibernate/hibernate-models/issues/85 -->
<!-- <exclusion>
<groupId>io.smallrye</groupId>
<artifactId>jandex</artifactId>
</exclusion> -->
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate.orm</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,22 @@ private static DotName createConstant(String fqcn) {
createConstant("org.hibernate.id.GUIDGenerator"),
createConstant("org.hibernate.id.IdentityGenerator"),
createConstant("org.hibernate.id.IncrementGenerator"),
createConstant("org.hibernate.id.NativeGenerator"),
createConstant("org.hibernate.id.SelectGenerator"),
createConstant("org.hibernate.id.UUIDGenerator"),
createConstant("org.hibernate.id.UUIDHexGenerator"),
createConstant("org.hibernate.id.enhanced.SequenceStyleGenerator"),
createConstant("org.hibernate.id.enhanced.TableGenerator"),
createConstant("org.hibernate.id.uuid.UuidGenerator"));
createConstant("org.hibernate.id.uuid.UuidGenerator"),
createConstant("org.hibernate.tuple.entity.CompositeGeneratorBuilder$CompositeBeforeExecutionGenerator"),
createConstant("org.hibernate.tuple.entity.CompositeGeneratorBuilder$CompositeOnExecutionGenerator"),
createConstant("org.hibernate.tuple.entity.CompositeGeneratorBuilder$DummyGenerator"));

public static final List<DotName> PACKAGE_ANNOTATIONS = List.of(
createConstant("jakarta.persistence.SequenceGenerator"),
createConstant("jakarta.persistence.SequenceGenerators"),
createConstant("jakarta.persistence.TableGenerator"),
createConstant("jakarta.persistence.TableGenerators"),
createConstant("org.hibernate.annotations.CollectionTypeRegistration"),
createConstant("org.hibernate.annotations.CompositeTypeRegistration"),
createConstant("org.hibernate.annotations.CompositeTypeRegistrations"),
Expand All @@ -107,11 +115,8 @@ private static DotName createConstant(String fqcn) {
createConstant("org.hibernate.annotations.NamedNativeQuery"),
createConstant("org.hibernate.annotations.NamedQueries"),
createConstant("org.hibernate.annotations.NamedQuery"),
createConstant("jakarta.persistence.SequenceGenerator"),
createConstant("jakarta.persistence.SequenceGenerators"),
createConstant("org.hibernate.annotations.NativeGenerator"),
createConstant("org.hibernate.annotations.SoftDelete"),
createConstant("jakarta.persistence.TableGenerator"),
createConstant("jakarta.persistence.TableGenerators"),
createConstant("org.hibernate.annotations.TypeRegistration"),
createConstant("org.hibernate.annotations.TypeRegistrations"));

Expand Down Expand Up @@ -215,6 +220,7 @@ private static DotName createConstant(String fqcn) {
createConstant("org.hibernate.annotations.AnyDiscriminator"),
createConstant("org.hibernate.annotations.AnyDiscriminatorValue"),
createConstant("org.hibernate.annotations.AnyDiscriminatorValues"),
createConstant("org.hibernate.annotations.AnyDiscriminatorImplicitValues"),
createConstant("org.hibernate.annotations.AnyKeyJavaClass"),
createConstant("org.hibernate.annotations.AnyKeyJavaType"),
createConstant("org.hibernate.annotations.AnyKeyJdbcType"),
Expand Down Expand Up @@ -250,7 +256,6 @@ private static DotName createConstant(String fqcn) {
createConstant("org.hibernate.annotations.ConcreteProxy"),
createConstant("org.hibernate.annotations.ConverterRegistration"),
createConstant("org.hibernate.annotations.ConverterRegistrations"),
createConstant("org.hibernate.boot.models.Copied"),
createConstant("org.hibernate.annotations.CreationTimestamp"),
createConstant("org.hibernate.annotations.CurrentTimestamp"),
createConstant("org.hibernate.annotations.DialectOverride$Check"),
Expand All @@ -269,8 +274,6 @@ private static DotName createConstant(String fqcn) {
createConstant("org.hibernate.annotations.DialectOverride$GeneratedColumns"),
createConstant("org.hibernate.annotations.DialectOverride$JoinFormula"),
createConstant("org.hibernate.annotations.DialectOverride$JoinFormulas"),
createConstant("org.hibernate.annotations.DialectOverride$OrderBy"),
createConstant("org.hibernate.annotations.DialectOverride$OrderBys"),
createConstant("org.hibernate.annotations.DialectOverride$OverridesAnnotation"),
createConstant("org.hibernate.annotations.DialectOverride$SQLDelete"),
createConstant("org.hibernate.annotations.DialectOverride$SQLDeleteAll"),
Expand Down Expand Up @@ -344,13 +347,13 @@ private static DotName createConstant(String fqcn) {
createConstant("org.hibernate.annotations.NamedQueries"),
createConstant("org.hibernate.annotations.NamedQuery"),
createConstant("org.hibernate.annotations.Nationalized"),
createConstant("org.hibernate.annotations.NativeGenerator"),
createConstant("org.hibernate.annotations.NaturalId"),
createConstant("org.hibernate.annotations.NaturalIdCache"),
createConstant("org.hibernate.annotations.NotFound"),
createConstant("org.hibernate.annotations.OnDelete"),
createConstant("org.hibernate.annotations.OptimisticLock"),
createConstant("org.hibernate.annotations.OptimisticLocking"),
createConstant("org.hibernate.annotations.OrderBy"),
createConstant("org.hibernate.annotations.ParamDef"),
createConstant("org.hibernate.annotations.Parameter"),
createConstant("org.hibernate.annotations.Parent"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.inject.Default;
import jakarta.persistence.PersistenceUnitTransactionType;
import jakarta.persistence.SharedCacheMode;
import jakarta.persistence.ValidationMode;
import jakarta.persistence.spi.PersistenceUnitTransactionType;
import jakarta.xml.bind.JAXBElement;

import org.hibernate.boot.archive.scan.spi.ClassDescriptor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.hibernate.metamodel.MappingMetamodel;
import org.hibernate.metamodel.mapping.SelectableConsumer;
import org.hibernate.metamodel.mapping.SelectableMapping;
import org.hibernate.persister.entity.AbstractEntityPersister;
import org.hibernate.persister.entity.EntityPersister;

public final class SchemaUtil {
Expand All @@ -21,9 +20,9 @@ private SchemaUtil() {

public static Set<String> getColumnNames(EntityManagerFactory entityManagerFactory, Class<?> entityType) {
Set<String> result = new HashSet<>();
AbstractEntityPersister persister = (AbstractEntityPersister) entityManagerFactory
.unwrap(SessionFactoryImplementor.class)
.getMetamodel().entityPersister(entityType);
var persister = entityManagerFactory.unwrap(SessionFactoryImplementor.class)
.getMappingMetamodel()
.getEntityDescriptor(entityType);
if (persister == null) {
return result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public class DatabaseOrmCompatibilityVersionTest {

@Test
public void testPropertiesPropagatedToStaticInit() {
assertThat(SettingsSpyingIdentifierGenerator.collectedSettings).hasSize(1);
// Two sets of settings: 0 is static init, 1 is runtime init.
assertThat(SettingsSpyingIdentifierGenerator.collectedSettings).hasSize(2);
Map<String, Object> settings = SettingsSpyingIdentifierGenerator.collectedSettings.get(0);
assertThat(settings).containsAllEntriesOf(Map.of(
AvailableSettings.TIMEZONE_DEFAULT_STORAGE, "NORMALIZE",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public class UnsupportedPropertiesTest {

@Test
public void testPropertiesPropagatedToStaticInit() {
assertThat(SettingsSpyingIdentifierGenerator.collectedSettings).hasSize(1);
// Two sets of settings: 0 is static init, 1 is runtime init.
assertThat(SettingsSpyingIdentifierGenerator.collectedSettings).hasSize(2);
Map<String, Object> settings = SettingsSpyingIdentifierGenerator.collectedSettings.get(0);
assertThat(settings)
.containsEntry("hibernate.some.unknown.key.static-and-runtime", "some-value-1")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.quarkus.deployment.index.IndexWrapper;
import io.quarkus.deployment.index.IndexingUtil;
Expand All @@ -45,6 +47,7 @@ public class ClassNamesTest {

private static final DotName RETENTION = DotName.createSimple(Retention.class.getName());
private static final DotName TARGET = DotName.createSimple(Target.class.getName());
private static final Logger log = LoggerFactory.getLogger(ClassNamesTest.class);

private static Index jpaIndex;
private static Index hibernateIndex;
Expand Down Expand Up @@ -149,7 +152,7 @@ public void testNoMissingJdbcJavaTypeClass() {
List<Type> typeParams = JandexUtil.resolveTypeParameters(basicJavaTypeImplInfo.name(), basicJavaTypeName,
hibernateAndJdkIndex);
Type jdbcJavaType = typeParams.get(0);
if (jdbcJavaType.kind() == Type.Kind.CLASS) {
if (jdbcJavaType.kind() == Type.Kind.CLASS || jdbcJavaType.kind() == Type.Kind.PARAMETERIZED_TYPE) {
jdbcJavaTypeNames.add(jdbcJavaType.name());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import jakarta.transaction.UserTransaction;

import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor;
import org.hibernate.Interceptor;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.type.Type;
Expand Down Expand Up @@ -113,7 +113,7 @@ public MyEntity(int id) {
}

@PersistenceUnitExtension // @ApplicationScoped is the default
public static class ApplicationScopedInterceptor extends EmptyInterceptor {
public static class ApplicationScopedInterceptor implements Interceptor {
private static final List<ApplicationScopedInterceptor> instances = Collections.synchronizedList(new ArrayList<>());
private static final List<Object> loadedIds = Collections.synchronizedList(new ArrayList<>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import jakarta.transaction.UserTransaction;

import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor;
import org.hibernate.Interceptor;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.type.Type;
Expand Down Expand Up @@ -116,7 +116,7 @@ public MyEntity(int id) {

@PersistenceUnitExtension
@Dependent
public static class DependentInterceptor extends EmptyInterceptor {
public static class DependentInterceptor implements Interceptor {
private static final List<DependentInterceptor> instances = Collections.synchronizedList(new ArrayList<>());
private static final List<Object> loadedIds = Collections.synchronizedList(new ArrayList<>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import jakarta.transaction.UserTransaction;

import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor;
import org.hibernate.Interceptor;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.type.Type;
Expand Down Expand Up @@ -118,7 +118,7 @@ public MyEntity(int id) {

@PersistenceUnitExtension
@TransactionScoped
public static class TransactionScopedInterceptor extends EmptyInterceptor {
public static class TransactionScopedInterceptor implements Interceptor {
private static final List<TransactionScopedInterceptor> instances = Collections.synchronizedList(new ArrayList<>());
private static final List<Object> loadedIds = Collections.synchronizedList(new ArrayList<>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import jakarta.transaction.UserTransaction;

import org.hibernate.CallbackException;
import org.hibernate.EmptyInterceptor;
import org.hibernate.Interceptor;
import org.hibernate.Session;
import org.hibernate.type.Type;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -105,7 +105,7 @@ public void test() throws Exception {
}

@PersistenceUnitExtension
public static class MyDefaultPUInterceptor extends EmptyInterceptor {
public static class MyDefaultPUInterceptor implements Interceptor {
private static final List<MyDefaultPUInterceptor> instances = Collections.synchronizedList(new ArrayList<>());
private static final List<Object> loadedIds = Collections.synchronizedList(new ArrayList<>());

Expand All @@ -124,7 +124,7 @@ public boolean onLoad(Object entity, Object id, Object[] state, String[] propert
}

@PersistenceUnitExtension("inventory")
public static class MyInventoryPUInterceptor extends EmptyInterceptor {
public static class MyInventoryPUInterceptor implements Interceptor {
private static final List<MyInventoryPUInterceptor> instances = Collections.synchronizedList(new ArrayList<>());
private static final List<Object> loadedIds = Collections.synchronizedList(new ArrayList<>());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public Object insert(String entityName, Object entity) {
return delegate.get().insert(entityName, entity);
}

@Override
public void insertMultiple(List<Object> entities) {
delegate.get().insertMultiple(entities);
}

@Override
public void update(Object entity) {
delegate.get().update(entity);
Expand All @@ -64,6 +69,11 @@ public void update(String entityName, Object entity) {
delegate.get().update(entityName, entity);
}

@Override
public void updateMultiple(List<Object> entities) {
delegate.get().updateMultiple(entities);
}

@Override
public void delete(Object entity) {
delegate.get().delete(entity);
Expand All @@ -74,6 +84,11 @@ public void delete(String entityName, Object entity) {
delegate.get().delete(entityName, entity);
}

@Override
public void deleteMultiple(List<Object> entities) {
delegate.get().deleteMultiple(entities);
}

@Override
public Object get(String entityName, Object id) {
return delegate.get().get(entityName, id);
Expand All @@ -84,6 +99,11 @@ public <T> T get(Class<T> entityClass, Object id) {
return delegate.get().get(entityClass, id);
}

@Override
public <T> List<T> getMultiple(Class<T> entityClass, List<Object> ids) {
return delegate.get().getMultiple(entityClass, ids);
}

@Override
public Object get(String entityName, Object id, LockMode lockMode) {
return delegate.get().get(entityName, id, lockMode);
Expand Down Expand Up @@ -433,6 +453,11 @@ public void upsert(String entityName, Object entity) {
delegate.get().upsert(entityName, entity);
}

@Override
public void upsertMultiple(List<Object> entities) {
delegate.get().upsertMultiple(entities);
}

@Override
public <T> T get(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id) {
return delegate.get().get(graph, graphSemantic, id);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,6 @@ protected void populate(String persistenceUnitName, SessionFactoryOptionsBuilder
options.disableJtaTransactionAccess();
}

final boolean allowRefreshDetachedEntity = runtimeSettings.getBoolean(
org.hibernate.cfg.AvailableSettings.ALLOW_REFRESH_DETACHED_ENTITY);
if (!allowRefreshDetachedEntity) {
options.disableRefreshDetachedEntity();
}

//Check for use of deprecated org.hibernate.jpa.AvailableSettings.SESSION_FACTORY_OBSERVER
final Object legacyObserver = runtimeSettings.get("hibernate.ejb.session_factory_observer");
if (legacyObserver != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import static org.hibernate.cfg.AvailableSettings.URL;
import static org.hibernate.cfg.AvailableSettings.USER;
import static org.hibernate.cfg.AvailableSettings.XML_MAPPING_ENABLED;
import static org.hibernate.internal.HEMLogging.messageLogger;
import static org.hibernate.internal.CoreLogging.messageLogger;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
Expand All @@ -30,7 +30,7 @@
import java.util.stream.Collectors;

import jakarta.persistence.PersistenceException;
import jakarta.persistence.spi.PersistenceUnitTransactionType;
import jakarta.persistence.PersistenceUnitTransactionType;

import org.hibernate.boot.CacheRegionDefinition;
import org.hibernate.boot.MetadataBuilder;
Expand All @@ -50,7 +50,7 @@
import org.hibernate.dialect.Dialect;
import org.hibernate.engine.jdbc.dialect.spi.DialectFactory;
import org.hibernate.integrator.spi.Integrator;
import org.hibernate.internal.EntityManagerMessageLogger;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jpa.boot.internal.StandardJpaScanEnvironmentImpl;
import org.hibernate.jpa.boot.spi.JpaSettings;
Expand Down Expand Up @@ -98,7 +98,7 @@ public class FastBootMetadataBuilder {
@Deprecated
private static final String ALLOW_ENHANCEMENT_AS_PROXY = "hibernate.bytecode.allow_enhancement_as_proxy";

private static final EntityManagerMessageLogger LOG = messageLogger(FastBootMetadataBuilder.class);
private static final CoreMessageLogger LOG = messageLogger(FastBootMetadataBuilder.class);

private final PersistenceUnitDescriptor persistenceUnit;
private final BuildTimeSettings buildTimeSettings;
Expand Down Expand Up @@ -593,7 +593,7 @@ private static void applyTransactionProperties(PersistenceUnitDescriptor persist
PersistenceUnitTransactionType transactionType = PersistenceUnitTransactionTypeHelper
.interpretTransactionType(configurationValues.get(JPA_TRANSACTION_TYPE));
if (transactionType == null) {
transactionType = persistenceUnit.getTransactionType();
transactionType = persistenceUnit.getPersistenceUnitTransactionType();
}
if (transactionType == null) {
// is it more appropriate to have this be based on bootstrap entry point (EE vs SE)?
Expand Down
Loading

0 comments on commit 80abb44

Please sign in to comment.