Skip to content

Commit

Permalink
[#1895] Upgrade Hibernate ORM to 7.0.0.Beta1
Browse files Browse the repository at this point in the history
  • Loading branch information
DavideD committed Aug 2, 2024
1 parent 81ffc42 commit 96a3da5
Show file tree
Hide file tree
Showing 41 changed files with 357 additions and 786 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ version = projectVersion
// ./gradlew clean build -PhibernateOrmVersion=5.6.15-SNAPSHOT
ext {
if ( !project.hasProperty('hibernateOrmVersion') ) {
hibernateOrmVersion = '6.6.0.CR2'
hibernateOrmVersion = '7.0.0.Beta1'
}
if ( !project.hasProperty( 'hibernateOrmGradlePluginVersion' ) ) {
// Same as ORM as default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@
import org.hibernate.AssertionFailure;
import org.hibernate.HibernateException;
import org.hibernate.PropertyValueException;
import org.hibernate.TransientObjectException;
import org.hibernate.action.internal.AbstractEntityInsertAction;
import org.hibernate.action.internal.BulkOperationCleanupAction;
import org.hibernate.action.internal.EntityDeleteAction;
import org.hibernate.action.internal.UnresolvedEntityInsertActions;
import org.hibernate.action.spi.AfterTransactionCompletionProcess;
import org.hibernate.action.spi.BeforeTransactionCompletionProcess;
import org.hibernate.action.spi.Executable;
import org.hibernate.cache.CacheException;
import org.hibernate.engine.internal.NonNullableTransientDependencies;
import org.hibernate.engine.spi.ActionQueue;
import org.hibernate.engine.spi.ComparableExecutable;
import org.hibernate.engine.spi.EntityEntry;
import org.hibernate.engine.spi.ExecutableList;
import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.engine.spi.SharedSessionContractImplementor;
import org.hibernate.metadata.ClassMetadata;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.proxy.HibernateProxy;
import org.hibernate.proxy.LazyInitializer;
Expand All @@ -59,7 +61,6 @@

import static java.lang.invoke.MethodHandles.lookup;
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
import static org.hibernate.reactive.util.impl.CompletionStages.failedFuture;
import static org.hibernate.reactive.util.impl.CompletionStages.loop;
import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture;

Expand Down Expand Up @@ -520,11 +521,21 @@ public CompletionStage<Void> executeInserts() {
*/
public CompletionStage<Void> executeActions() {
if ( hasUnresolvedEntityInsertActions() ) {
return failedFuture( new IllegalStateException( "About to execute actions, but there are unresolved entity insert actions." ) );
final AbstractEntityInsertAction insertAction = unresolvedInsertions
.getDependentEntityInsertActions()
.iterator()
.next();
final NonNullableTransientDependencies transientEntities = insertAction.findNonNullableTransientEntities();
final Object transientEntity = transientEntities.getNonNullableTransientEntities().iterator().next();
final String path = transientEntities.getNonNullableTransientPropertyPaths(transientEntity).iterator().next();
//TODO: should be TransientPropertyValueException
throw new TransientObjectException( "Persistent instance of '" + insertAction.getEntityName()
+ "' with id '" + insertAction.getId()
+ "' references an unsaved transient instance via attribute '" + path
+ "' (save the transient instance before flushing)" );
}

CompletionStage<Void> ret = voidFuture();

for ( OrderedActions action : ORDERED_OPERATIONS ) {
ret = ret.thenCompose( v -> executeActions( action.getActions( this ) ) );
}
Expand Down Expand Up @@ -738,26 +749,6 @@ public int numberOfInsertions() {
return insertions.size();
}

// public TransactionCompletionProcesses getTransactionCompletionProcesses() {
// return new TransactionCompletionProcesses( beforeTransactionProcesses(), afterTransactionProcesses() );
// }
//
// /**
// * Bind transaction completion processes to make them shared between primary and secondary session.
// * Transaction completion processes are always executed by transaction owner (primary session),
// * but can be registered using secondary session too.
// *
// * @param processes Transaction completion processes.
// * @param isTransactionCoordinatorShared Flag indicating shared transaction context.
// */
// public void setTransactionCompletionProcesses(
// TransactionCompletionProcesses processes,
// boolean isTransactionCoordinatorShared) {
// this.isTransactionCoordinatorShared = isTransactionCoordinatorShared;
// this.beforeTransactionProcesses = processes.beforeTransactionCompletionProcesses;
// this.afterTransactionProcesses = processes.afterTransactionCompletionProcesses;
// }

public void sortCollectionActions() {
if ( isOrderUpdatesEnabled() ) {
// sort the updates by fk
Expand Down Expand Up @@ -864,32 +855,6 @@ public void unScheduleDeletion(EntityEntry entry, Object rescuedEntity) {
throw new AssertionFailure( "Unable to perform un-delete for instance " + entry.getEntityName() );
}

// /**
// * Used by the owning session to explicitly control serialization of the action queue
// *
// * @param oos The stream to which the action queue should get written
// *
// * @throws IOException Indicates an error writing to the stream
// */
// public void serialize(ObjectOutputStream oos) throws IOException {
// LOG.trace( "Serializing action-queue" );
// if ( unresolvedInsertions == null ) {
// unresolvedInsertions = new UnresolvedEntityInsertActions();
// }
// unresolvedInsertions.serialize( oos );
//
// for ( ListProvider<?> p : EXECUTABLE_LISTS_MAP.values() ) {
// ExecutableList<?> l = p.get( this );
// if ( l == null ) {
// oos.writeBoolean( false );
// }
// else {
// oos.writeBoolean( true );
// l.writeExternal( oos );
// }
// }
// }

private abstract static class AbstractTransactionCompletionProcessQueue<T,U> {
final ReactiveSession session;

Expand Down Expand Up @@ -994,21 +959,6 @@ public CompletionStage<Void> afterTransactionCompletion(boolean success) {
}
}

// /**
// * Wrapper class allowing to bind the same transaction completion process queues in different sessions.
// */
// public static class TransactionCompletionProcesses {
// private final BeforeTransactionCompletionProcessQueue beforeTransactionCompletionProcesses;
// private final AfterTransactionCompletionProcessQueue afterTransactionCompletionProcesses;
//
// private TransactionCompletionProcesses(
// BeforeTransactionCompletionProcessQueue beforeTransactionCompletionProcessQueue,
// AfterTransactionCompletionProcessQueue afterTransactionCompletionProcessQueue) {
// this.beforeTransactionCompletionProcesses = beforeTransactionCompletionProcessQueue;
// this.afterTransactionCompletionProcesses = afterTransactionCompletionProcessQueue;
// }
// }

/**
* Order the {@link #insertions} queue such that we group inserts against the same entity together (without
* violating constraints). The original order is generated by cascade order, which in turn is based on the
Expand Down Expand Up @@ -1152,26 +1102,23 @@ public void sort(List<ReactiveEntityInsertActionHolder> insertions) {
*/
private void addParentChildEntityNames(ReactiveEntityInsertAction action, BatchIdentifier batchIdentifier) {
Object[] propertyValues = action.getState();
ClassMetadata classMetadata = action.getPersister().getClassMetadata();
if ( classMetadata != null ) {
Type[] propertyTypes = classMetadata.getPropertyTypes();
Type identifierType = classMetadata.getIdentifierType();

for ( int i = 0; i < propertyValues.length; i++ ) {
Object value = propertyValues[i];
if (value!=null) {
Type type = propertyTypes[i];
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, value );
}
Type[] propertyTypes = action.getPersister().getPropertyTypes();
Type identifierType = action.getPersister().getIdentifierType();

for ( int i = 0; i < propertyValues.length; i++ ) {
Object value = propertyValues[i];
if (value!=null) {
Type type = propertyTypes[i];
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, value );
}
}

if ( identifierType.isComponentType() ) {
CompositeType compositeType = (CompositeType) identifierType;
Type[] compositeIdentifierTypes = compositeType.getSubtypes();
if ( identifierType.isComponentType() ) {
CompositeType compositeType = (CompositeType) identifierType;
Type[] compositeIdentifierTypes = compositeType.getSubtypes();

for ( Type type : compositeIdentifierTypes ) {
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, null );
}
for ( Type type : compositeIdentifierTypes ) {
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, null );
}
}
}
Expand Down Expand Up @@ -1275,10 +1222,9 @@ public boolean equals(Object o) {
if ( this == o ) {
return true;
}
if ( !( o instanceof BatchIdentifier ) ) {
if ( !( o instanceof BatchIdentifier that ) ) {
return false;
}
BatchIdentifier that = (BatchIdentifier) o;
return Objects.equals( entityName, that.entityName );
}

Expand Down Expand Up @@ -1315,9 +1261,7 @@ boolean hasAnyChildEntityNames(BatchIdentifier batchIdentifier) {
/**
* Check if this {@link BatchIdentifier} has a parent or grandparent
* matching the given {@link BatchIdentifier reference.
*
* @param batchIdentifier {@link BatchIdentifier} reference
*
* @return this {@link BatchIdentifier} has a parent matching the given {@link BatchIdentifier reference
*/
boolean hasParent(BatchIdentifier batchIdentifier) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ public class ReactiveGeneratedValuesHelper {
*
* @see GeneratedValuesHelper#getGeneratedValuesDelegate(EntityPersister, EventType)
*/
public static GeneratedValuesMutationDelegate getGeneratedValuesDelegate(
EntityPersister persister,
EventType timing) {
public static GeneratedValuesMutationDelegate getGeneratedValuesDelegate(EntityPersister persister, EventType timing) {
final boolean hasGeneratedProperties = !persister.getGeneratedProperties( timing ).isEmpty();
final boolean hasRowId = timing == EventType.INSERT && persister.getRowIdMapping() != null;
final Dialect dialect = persister.getFactory().getJdbcServices().getDialect();

if ( hasRowId && dialect.supportsInsertReturning() && dialect.supportsInsertReturningRowId()
if ( hasRowId
&& dialect.supportsInsertReturning()
&& dialect.supportsInsertReturningRowId()
&& noCustomSql( persister, timing ) ) {
// Special case for RowId on INSERT, since GetGeneratedKeysDelegate doesn't support it
// make InsertReturningDelegate the preferred method if the dialect supports it
Expand Down

This file was deleted.

Loading

0 comments on commit 96a3da5

Please sign in to comment.