Skip to content

Commit

Permalink
Upgrade to Hibernate ORM 6.3.1.Final
Browse files Browse the repository at this point in the history
Co-authored-by: Stéphane Épardaud <stef@epardaud.fr>
  • Loading branch information
yrodiere and FroMage committed Nov 6, 2023
1 parent c18cfc3 commit bc84cbf
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 68 deletions.
8 changes: 5 additions & 3 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,11 @@
<commons-lang3.version>3.12.0</commons-lang3.version>
<commons-codec.version>1.16.0</commons-codec.version>
<classmate.version>1.5.1</classmate.version>
<!-- When updating, align bytebuddy.version to Hibernate needs as well (just below),
as well as hibernate-orm.version-for-documentation in docs/pom.xml -->
<hibernate-orm.version>6.2.13.Final</hibernate-orm.version>
<!-- WARNING: When updating, also align other properties on this version:
bytebuddy.version (just below), hibernate-orm.version-for-documentation (in docs/pom.xml)
and antlr.version.version in build-parent/pom.xml
WARNING again for diffs that don't provide enough context: when updating, see above -->
<hibernate-orm.version>6.3.1.Final</hibernate-orm.version>
<bytebuddy.version>1.14.7</bytebuddy.version> <!-- Version controlled by Hibernate ORM's needs -->
<hibernate-commons-annotations.version>6.0.6.Final</hibernate-commons-annotations.version> <!-- version controlled by Hibernate ORM -->
<hibernate-reactive.version>2.0.6.Final</hibernate-reactive.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ private HibernateOrmTypes() {
DotName.createSimple("org.hibernate.annotations.AnyKeyJavaType"),
DotName.createSimple("org.hibernate.annotations.AnyKeyJdbcType"),
DotName.createSimple("org.hibernate.annotations.AnyKeyJdbcTypeCode"),
DotName.createSimple("org.hibernate.annotations.Array"),
DotName.createSimple("org.hibernate.annotations.AttributeAccessor"),
DotName.createSimple("org.hibernate.annotations.AttributeBinderType"),
DotName.createSimple("org.hibernate.annotations.Bag"),
Expand All @@ -149,6 +150,7 @@ private HibernateOrmTypes() {
DotName.createSimple("org.hibernate.annotations.Cascade"),
DotName.createSimple("org.hibernate.annotations.Check"),
DotName.createSimple("org.hibernate.annotations.Checks"),
DotName.createSimple("org.hibernate.annotations.Collate"),
DotName.createSimple("org.hibernate.annotations.CollectionId"),
DotName.createSimple("org.hibernate.annotations.CollectionIdJavaType"),
DotName.createSimple("org.hibernate.annotations.CollectionIdJdbcType"),
Expand Down Expand Up @@ -190,6 +192,20 @@ private HibernateOrmTypes() {
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$SQLDelete"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLDeleteAll"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLDeleteAlls"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLDeletes"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLInsert"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLInserts"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLOrder"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLOrders"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLRestriction"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLRestrictions"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLSelect"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLSelects"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLUpdate"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$SQLUpdates"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$Version"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$Where"),
DotName.createSimple("org.hibernate.annotations.DialectOverride$Wheres"),
Expand All @@ -203,6 +219,8 @@ private HibernateOrmTypes() {
DotName.createSimple("org.hibernate.annotations.Fetch"),
DotName.createSimple("org.hibernate.annotations.FetchProfile"),
DotName.createSimple("org.hibernate.annotations.FetchProfile$FetchOverride"),
DotName.createSimple("org.hibernate.annotations.FetchProfileOverride"),
DotName.createSimple("org.hibernate.annotations.FetchProfileOverrides"),
DotName.createSimple("org.hibernate.annotations.FetchProfiles"),
DotName.createSimple("org.hibernate.annotations.Filter"),
DotName.createSimple("org.hibernate.annotations.FilterDef"),
Expand Down Expand Up @@ -274,6 +292,9 @@ private HibernateOrmTypes() {
DotName.createSimple("org.hibernate.annotations.SQLDeletes"),
DotName.createSimple("org.hibernate.annotations.SQLInsert"),
DotName.createSimple("org.hibernate.annotations.SQLInserts"),
DotName.createSimple("org.hibernate.annotations.SQLJoinTableRestriction"),
DotName.createSimple("org.hibernate.annotations.SQLOrder"),
DotName.createSimple("org.hibernate.annotations.SQLRestriction"),
DotName.createSimple("org.hibernate.annotations.SQLSelect"),
DotName.createSimple("org.hibernate.annotations.SQLUpdate"),
DotName.createSimple("org.hibernate.annotations.SQLUpdates"),
Expand All @@ -300,6 +321,7 @@ private HibernateOrmTypes() {
DotName.createSimple("org.hibernate.annotations.UpdateTimestamp"),
DotName.createSimple("org.hibernate.annotations.UuidGenerator"),
DotName.createSimple("org.hibernate.annotations.ValueGenerationType"),
DotName.createSimple("org.hibernate.annotations.View"),
DotName.createSimple("org.hibernate.annotations.Where"),
DotName.createSimple("org.hibernate.annotations.WhereJoinTable"));

Expand Down Expand Up @@ -352,5 +374,6 @@ private HibernateOrmTypes() {
DotName.createSimple("java.util.Locale"),
DotName.createSimple("java.util.Map$Entry"),
DotName.createSimple("java.util.TimeZone"),
DotName.createSimple("java.util.UUID"));
DotName.createSimple("java.util.UUID"),
DotName.createSimple("java.lang.Void"));
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public String checkPuInfoWithFailingDDLGeneration() {
+ TypeWithUnsupportedSqlCode.UNSUPPORTED_SQL_CODE + "))");
// Drop script generation doesn't involve column types, so it didn't fail
assertThat(pu.getDropDDL())
.contains("drop table MyEntityTable if exists");
.contains("drop table if exists MyEntityTable");

return "OK";
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ public LoadState isLoadedWithReference(Object proxy, String property) {

@Override
public LoadState isLoaded(Object o) {
return PersistenceUtilHelper.isLoaded(o);
return PersistenceUtilHelper.getLoadState(o);
}
}
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
package io.quarkus.hibernate.orm.runtime;

import java.util.List;
import java.util.function.Supplier;

import jakarta.persistence.EntityGraph;
import jakarta.persistence.criteria.CriteriaDelete;
import jakarta.persistence.criteria.CriteriaQuery;
import jakarta.persistence.criteria.CriteriaUpdate;

import org.hibernate.HibernateException;
import org.hibernate.LockMode;
import org.hibernate.SessionFactory;
import org.hibernate.StatelessSession;
import org.hibernate.Transaction;
import org.hibernate.graph.GraphSemantic;
import org.hibernate.graph.RootGraph;
import org.hibernate.jdbc.ReturningWork;
import org.hibernate.jdbc.Work;
import org.hibernate.procedure.ProcedureCall;
Expand Down Expand Up @@ -349,4 +354,54 @@ public NativeQuery getNamedNativeQuery(String name) {
public NativeQuery getNamedNativeQuery(String name, String resultSetMapping) {
return delegate.get().getNamedNativeQuery(name, resultSetMapping);
}

@Override
public <T> RootGraph<T> createEntityGraph(Class<T> rootType) {
return delegate.get().createEntityGraph(rootType);
}

@Override
public RootGraph<?> createEntityGraph(String graphName) {
return delegate.get().createEntityGraph(graphName);
}

@Override
public <T> RootGraph<T> createEntityGraph(Class<T> rootType, String graphName) {
return delegate.get().createEntityGraph(rootType, graphName);
}

@Override
public RootGraph<?> getEntityGraph(String graphName) {
return delegate.get().getEntityGraph(graphName);
}

@Override
public <T> List<EntityGraph<? super T>> getEntityGraphs(Class<T> entityClass) {
return delegate.get().getEntityGraphs(entityClass);
}

@Override
public SessionFactory getFactory() {
return delegate.get().getFactory();
}

@Override
public void upsert(Object entity) {
delegate.get().upsert(entity);
}

@Override
public void upsert(String entityName, Object entity) {
delegate.get().upsert(entityName, entity);
}

@Override
public <T> T get(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id) {
return delegate.get().get(graph, graphSemantic, id);
}

@Override
public <T> T get(EntityGraph<T> graph, GraphSemantic graphSemantic, Object id, LockMode lockMode) {
return delegate.get().get(graph, graphSemantic, id, lockMode);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import jakarta.persistence.spi.PersistenceUnitTransactionType;

import org.hibernate.bytecode.enhance.spi.EnhancementContext;
import org.hibernate.bytecode.spi.ClassTransformer;
import org.hibernate.jpa.boot.spi.PersistenceUnitDescriptor;

import io.quarkus.runtime.annotations.RecordableConstructor;
Expand Down Expand Up @@ -193,4 +194,10 @@ public String toString() {
+ ", validationMode=" + validationMode + ", sharedCachemode=" + sharedCacheMode + ", managedClassNames="
+ managedClassNames + ", properties=" + properties + '}';
}

@Override
public ClassTransformer getClassTransformer() {
// We transform classes during the build, not on bootstrap.
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@
import jakarta.transaction.TransactionManager;
import jakarta.transaction.UserTransaction;

import org.hibernate.engine.transaction.jta.platform.internal.JtaSynchronizationStrategy;
import org.hibernate.engine.transaction.internal.jta.JtaStatusHelper;
import org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerAccess;
import org.hibernate.engine.transaction.jta.platform.internal.TransactionManagerBasedSynchronizationStrategy;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatform;
import org.hibernate.engine.transaction.jta.platform.spi.JtaPlatformException;

public final class QuarkusJtaPlatform implements JtaPlatform, TransactionManagerAccess {

public static final QuarkusJtaPlatform INSTANCE = new QuarkusJtaPlatform();

private final JtaSynchronizationStrategy tmSynchronizationStrategy = new TransactionManagerBasedSynchronizationStrategy(
this);
private volatile TransactionManager transactionManager;
private volatile UserTransaction userTransaction;

Expand All @@ -42,7 +40,7 @@ public TransactionManager getTransactionManager() {
@Override
public UserTransaction retrieveUserTransaction() {
UserTransaction userTransaction = this.userTransaction;
if (this.userTransaction == null) {
if (userTransaction == null) {
userTransaction = com.arjuna.ats.jta.UserTransaction.userTransaction();
this.userTransaction = userTransaction;
}
Expand All @@ -56,12 +54,16 @@ public Object getTransactionIdentifier(final Transaction transaction) {

@Override
public void registerSynchronization(Synchronization synchronization) {
this.tmSynchronizationStrategy.registerSynchronization(synchronization);
try {
getTransactionManager().getTransaction().registerSynchronization(synchronization);
} catch (Exception e) {
throw new JtaPlatformException("Could not access JTA Transaction to register synchronization", e);
}
}

@Override
public boolean canRegisterSynchronization() {
return this.tmSynchronizationStrategy.canRegisterSynchronization();
return JtaStatusHelper.isActive(QuarkusJtaPlatform.this.getTransactionManager());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public SessionFactoryObserverForNamedQueryValidation(MetadataImplementor metadat
public void sessionFactoryCreated(SessionFactory factory) {
SessionFactoryImplementor sessionFactory = (SessionFactoryImplementor) factory;
final QueryEngine queryEngine = sessionFactory.getQueryEngine();
queryEngine.prepare(sessionFactory, metadata);
queryEngine.getNamedObjectRepository().prepare(sessionFactory, metadata);
if (sessionFactory.getSessionFactoryOptions().isNamedQueryStartupCheckingEnabled()) {
queryEngine.validateNamedQueries();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ public StandardServiceRegistry build() {
settingsCopy.putAll(settings);
settingsCopy.put(org.hibernate.boot.cfgxml.spi.CfgXmlAccessService.LOADED_CONFIG_KEY, aggregatedCfgXml);

return new StandardServiceRegistryImpl(autoCloseRegistry, bootstrapServiceRegistry, initiators,
return StandardServiceRegistryImpl.create(autoCloseRegistry, bootstrapServiceRegistry, initiators,
providedServices, settingsCopy);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1386,4 +1386,44 @@ public void close() {
}
}
}

@Override
public <T> RootGraph<T> createEntityGraph(Class<T> rootType, String graphName) {
try (SessionResult emr = acquireSession()) {
return emr.session.createEntityGraph(rootType, graphName);
}
}

@Override
public SessionFactory getFactory() {
return sessionFactory;
}

@Override
public int getFetchBatchSize() {
try (SessionResult emr = acquireSession()) {
return emr.session.getFetchBatchSize();
}
}

@Override
public void setFetchBatchSize(int batchSize) {
try (SessionResult emr = acquireSession()) {
emr.session.setFetchBatchSize(batchSize);
}
}

@Override
public boolean isSubselectFetchingEnabled() {
try (SessionResult emr = acquireSession()) {
return emr.session.isSubselectFetchingEnabled();
}
}

@Override
public void setSubselectFetchingEnabled(boolean enabled) {
try (SessionResult emr = acquireSession()) {
emr.session.setSubselectFetchingEnabled(enabled);
}
}
}
Loading

0 comments on commit bc84cbf

Please sign in to comment.