Skip to content

Commit 10a9d1d

Browse files
committed
[hibernate#1895] Upgrade Hibernate ORM to 7.0.0.Beta3
Notes: * The Hibernate Gradle plugin has not been released yet, so we keep it to 7.0.0.Beta2 * XML sql data type is not supported: eclipse-vertx/vertx-sql-client#1475 * Stop using `org.hibernate.dialect.DialectDelegateWrapper` (not required anymore) * Remove `ReactiveOracleSqlAstTranslator` (not required anymore) * Only process parameters for native queries. See hibernate#2012 * Remove `ReactiveIdentifierGeneratorFactory`: the service doesn't exist anymore in ORM * Add `persist(String, Object)` to the session * Remove test for `hibernate.create_empty_composites.enabled`: see [HHH-18222](https://hibernate.atlassian.net/browse/HHH-18222) * Contains some clean ups * There are still some issues with embeddable mapped as JSON and native queries: See hibernate#1999
1 parent 762b5e8 commit 10a9d1d

File tree

131 files changed

+2607
-2439
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

131 files changed

+2607
-2439
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Hibernate Reactive has been tested with:
3737
- CockroachDB v24
3838
- MS SQL Server 2022
3939
- Oracle 23
40-
- [Hibernate ORM][] 6.6.3.Final
40+
- [Hibernate ORM][] 7.0.0.Beta3
4141
- [Vert.x Reactive PostgreSQL Client](https://vertx.io/docs/vertx-pg-client/java/) 4.5.11
4242
- [Vert.x Reactive MySQL Client](https://vertx.io/docs/vertx-mysql-client/java/) 4.5.11
4343
- [Vert.x Reactive Db2 Client](https://vertx.io/docs/vertx-db2-client/java/) 4.5.11

documentation/src/main/asciidoc/reference/introduction.adoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -578,8 +578,8 @@ custom reactive identifier generator.
578578

579579
=== JSON Mapping
580580

581-
:orm-json-basic-mapping: https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#basic-mapping-json
582-
:orm-json-embeddable-mapping: https://docs.jboss.org/hibernate/orm/6.6/userguide/html_single/Hibernate_User_Guide.html#_jsonxml_aggregate_embeddable_mapping
581+
:orm-json-basic-mapping: https://docs.jboss.org/hibernate/orm/7.0/userguide/html_single/Hibernate_User_Guide.html#basic-mapping-json
582+
:orm-json-embeddable-mapping: https://docs.jboss.org/hibernate/orm/7.0/userguide/html_single/Hibernate_User_Guide.html#_jsonxml_aggregate_embeddable_mapping
583583
:string-to-json-converter: https://github.com/hibernate/hibernate-reactive/blob/main/hibernate-reactive-core/src/test/java/org/hibernate/reactive/types/StringToJsonConverter.java
584584

585585
Like in Hibernate ORM, it's possible to map a JSON field using the {orm-json-basic-mapping}[SqlTypes.JSON]

gradle.properties

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ org.gradle.java.installations.auto-download=false
3535
#enableMavenLocalRepo = true
3636

3737
# The default Hibernate ORM version (override using `-PhibernateOrmVersion=the.version.you.want`)
38-
hibernateOrmVersion = 6.6.3.Final
38+
hibernateOrmVersion = 7.0.0.Beta3
3939

4040
# Override default Hibernate ORM Gradle plugin version
4141
# Using the stable version because I don't know how to configure the build to download the snapshot version from
4242
# a remote repository
43-
#hibernateOrmGradlePluginVersion = 6.6.3.Final
43+
hibernateOrmGradlePluginVersion = 7.0.0.Beta2
4444

4545
# If set to true, skip Hibernate ORM version parsing (default is true, if set to null)
4646
# this is required when using intervals or weird versions or the build will fail

hibernate-reactive-core/src/main/java/org/hibernate/reactive/adaptor/impl/PreparedStatementAdaptor.java

+13-7
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,6 @@
55
*/
66
package org.hibernate.reactive.adaptor.impl;
77

8-
import io.vertx.core.buffer.Buffer;
9-
10-
import org.hibernate.AssertionFailure;
11-
import org.hibernate.HibernateException;
12-
138
import java.io.ByteArrayOutputStream;
149
import java.io.IOException;
1510
import java.io.InputStream;
@@ -39,12 +34,23 @@
3934
import java.util.Calendar;
4035
import java.util.function.Function;
4136

37+
import org.hibernate.AssertionFailure;
38+
import org.hibernate.HibernateException;
39+
import org.hibernate.reactive.logging.impl.Log;
40+
41+
import io.vertx.core.buffer.Buffer;
42+
43+
import static java.lang.invoke.MethodHandles.lookup;
44+
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
45+
4246
/**
4347
* Collects parameter bindings from Hibernate core code
4448
* that expects a JDBC {@link PreparedStatement}.
4549
*/
4650
public class PreparedStatementAdaptor implements PreparedStatement {
4751

52+
private static final Log LOG = make( Log.class, lookup() );
53+
4854
@FunctionalInterface
4955
public interface Binder {
5056
void bind(PreparedStatement statement) throws SQLException;
@@ -315,7 +321,7 @@ public void setNClob(int parameterIndex, Reader reader, long length) {
315321

316322
@Override
317323
public void setSQLXML(int parameterIndex, SQLXML xmlObject) {
318-
throw new UnsupportedOperationException();
324+
throw LOG.unsupportedXmlType();
319325
}
320326

321327
@Override
@@ -540,7 +546,7 @@ public int[] executeBatch() {
540546

541547
@Override
542548
public Connection getConnection() {
543-
throw new UnsupportedOperationException();
549+
throw LOG.unexpectedConnectionRequest();
544550
}
545551

546552
@Override

hibernate-reactive-core/src/main/java/org/hibernate/reactive/adaptor/impl/ResultSetAdaptor.java

+9-4
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@
3636
import java.util.NoSuchElementException;
3737
import java.util.function.Function;
3838

39-
import org.hibernate.engine.jdbc.BlobProxy;
40-
import org.hibernate.engine.jdbc.ClobProxy;
39+
import org.hibernate.engine.jdbc.proxy.BlobProxy;
40+
import org.hibernate.engine.jdbc.proxy.ClobProxy;
41+
import org.hibernate.reactive.logging.impl.Log;
4142
import org.hibernate.type.descriptor.jdbc.JdbcType;
4243

4344
import io.vertx.core.buffer.Buffer;
@@ -48,15 +49,19 @@
4849
import io.vertx.sqlclient.desc.ColumnDescriptor;
4950
import io.vertx.sqlclient.impl.RowBase;
5051

52+
import static java.lang.invoke.MethodHandles.lookup;
5153
import static java.util.Collections.emptyList;
5254
import static java.util.Objects.requireNonNull;
55+
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
5356

5457
/**
5558
* An adaptor that allows Hibernate core code which expects a JDBC
5659
* {@code ResultSet} to read values from Vert.x's {@code RowSet}.
5760
*/
5861
public class ResultSetAdaptor implements ResultSet {
5962

63+
private static final Log LOG = make( Log.class, lookup() );
64+
6065
private final Iterator<? extends Row> iterator;
6166

6267
private final List<ColumnDescriptor> columnDescriptors;
@@ -866,12 +871,12 @@ public NClob getNClob(String columnLabel) {
866871

867872
@Override
868873
public SQLXML getSQLXML(int columnIndex) {
869-
throw new UnsupportedOperationException();
874+
throw LOG.unsupportedXmlType();
870875
}
871876

872877
@Override
873878
public SQLXML getSQLXML(String columnLabel) {
874-
throw new UnsupportedOperationException();
879+
throw LOG.unsupportedXmlType();
875880
}
876881

877882
@Override

hibernate-reactive-core/src/main/java/org/hibernate/reactive/boot/spi/ReactiveMetadataImplementor.java

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import org.hibernate.boot.spi.AbstractDelegatingMetadata;
99
import org.hibernate.boot.spi.MetadataImplementor;
10-
import org.hibernate.engine.spi.SessionFactoryImplementor;
1110
import org.hibernate.query.named.NamedObjectRepository;
1211
import org.hibernate.reactive.query.internal.ReactiveNamedObjectRepositoryImpl;
1312

@@ -18,7 +17,7 @@ public ReactiveMetadataImplementor(MetadataImplementor delegate) {
1817
}
1918

2019
@Override
21-
public NamedObjectRepository buildNamedQueryRepository(SessionFactoryImplementor sessionFactory) {
22-
return new ReactiveNamedObjectRepositoryImpl( delegate().buildNamedQueryRepository( sessionFactory ) );
20+
public NamedObjectRepository buildNamedQueryRepository() {
21+
return new ReactiveNamedObjectRepositoryImpl( super.buildNamedQueryRepository() );
2322
}
2423
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/dialect/ReactiveOracleSqlAstTranslator.java

-43
This file was deleted.

hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/ReactiveActionQueue.java

+30-86
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,22 @@
2121
import org.hibernate.AssertionFailure;
2222
import org.hibernate.HibernateException;
2323
import org.hibernate.PropertyValueException;
24+
import org.hibernate.TransientObjectException;
25+
import org.hibernate.action.internal.AbstractEntityInsertAction;
2426
import org.hibernate.action.internal.BulkOperationCleanupAction;
2527
import org.hibernate.action.internal.EntityDeleteAction;
2628
import org.hibernate.action.internal.UnresolvedEntityInsertActions;
2729
import org.hibernate.action.spi.AfterTransactionCompletionProcess;
2830
import org.hibernate.action.spi.BeforeTransactionCompletionProcess;
2931
import org.hibernate.action.spi.Executable;
3032
import org.hibernate.cache.CacheException;
33+
import org.hibernate.engine.internal.NonNullableTransientDependencies;
3134
import org.hibernate.engine.spi.ActionQueue;
3235
import org.hibernate.engine.spi.ComparableExecutable;
3336
import org.hibernate.engine.spi.EntityEntry;
3437
import org.hibernate.engine.spi.ExecutableList;
3538
import org.hibernate.engine.spi.SessionFactoryImplementor;
3639
import org.hibernate.engine.spi.SharedSessionContractImplementor;
37-
import org.hibernate.metadata.ClassMetadata;
3840
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
3941
import org.hibernate.proxy.HibernateProxy;
4042
import org.hibernate.proxy.LazyInitializer;
@@ -59,7 +61,6 @@
5961

6062
import static java.lang.invoke.MethodHandles.lookup;
6163
import static org.hibernate.reactive.logging.impl.LoggerFactory.make;
62-
import static org.hibernate.reactive.util.impl.CompletionStages.failedFuture;
6364
import static org.hibernate.reactive.util.impl.CompletionStages.loop;
6465
import static org.hibernate.reactive.util.impl.CompletionStages.voidFuture;
6566

@@ -520,11 +521,21 @@ public CompletionStage<Void> executeInserts() {
520521
*/
521522
public CompletionStage<Void> executeActions() {
522523
if ( hasUnresolvedEntityInsertActions() ) {
523-
return failedFuture( new IllegalStateException( "About to execute actions, but there are unresolved entity insert actions." ) );
524+
final AbstractEntityInsertAction insertAction = unresolvedInsertions
525+
.getDependentEntityInsertActions()
526+
.iterator()
527+
.next();
528+
final NonNullableTransientDependencies transientEntities = insertAction.findNonNullableTransientEntities();
529+
final Object transientEntity = transientEntities.getNonNullableTransientEntities().iterator().next();
530+
final String path = transientEntities.getNonNullableTransientPropertyPaths(transientEntity).iterator().next();
531+
//TODO: should be TransientPropertyValueException
532+
throw new TransientObjectException( "Persistent instance of '" + insertAction.getEntityName()
533+
+ "' with id '" + insertAction.getId()
534+
+ "' references an unsaved transient instance via attribute '" + path
535+
+ "' (save the transient instance before flushing)" );
524536
}
525537

526538
CompletionStage<Void> ret = voidFuture();
527-
528539
for ( OrderedActions action : ORDERED_OPERATIONS ) {
529540
ret = ret.thenCompose( v -> executeActions( action.getActions( this ) ) );
530541
}
@@ -738,26 +749,6 @@ public int numberOfInsertions() {
738749
return insertions.size();
739750
}
740751

741-
// public TransactionCompletionProcesses getTransactionCompletionProcesses() {
742-
// return new TransactionCompletionProcesses( beforeTransactionProcesses(), afterTransactionProcesses() );
743-
// }
744-
//
745-
// /**
746-
// * Bind transaction completion processes to make them shared between primary and secondary session.
747-
// * Transaction completion processes are always executed by transaction owner (primary session),
748-
// * but can be registered using secondary session too.
749-
// *
750-
// * @param processes Transaction completion processes.
751-
// * @param isTransactionCoordinatorShared Flag indicating shared transaction context.
752-
// */
753-
// public void setTransactionCompletionProcesses(
754-
// TransactionCompletionProcesses processes,
755-
// boolean isTransactionCoordinatorShared) {
756-
// this.isTransactionCoordinatorShared = isTransactionCoordinatorShared;
757-
// this.beforeTransactionProcesses = processes.beforeTransactionCompletionProcesses;
758-
// this.afterTransactionProcesses = processes.afterTransactionCompletionProcesses;
759-
// }
760-
761752
public void sortCollectionActions() {
762753
if ( isOrderUpdatesEnabled() ) {
763754
// sort the updates by fk
@@ -864,32 +855,6 @@ public void unScheduleDeletion(EntityEntry entry, Object rescuedEntity) {
864855
throw new AssertionFailure( "Unable to perform un-delete for instance " + entry.getEntityName() );
865856
}
866857

867-
// /**
868-
// * Used by the owning session to explicitly control serialization of the action queue
869-
// *
870-
// * @param oos The stream to which the action queue should get written
871-
// *
872-
// * @throws IOException Indicates an error writing to the stream
873-
// */
874-
// public void serialize(ObjectOutputStream oos) throws IOException {
875-
// LOG.trace( "Serializing action-queue" );
876-
// if ( unresolvedInsertions == null ) {
877-
// unresolvedInsertions = new UnresolvedEntityInsertActions();
878-
// }
879-
// unresolvedInsertions.serialize( oos );
880-
//
881-
// for ( ListProvider<?> p : EXECUTABLE_LISTS_MAP.values() ) {
882-
// ExecutableList<?> l = p.get( this );
883-
// if ( l == null ) {
884-
// oos.writeBoolean( false );
885-
// }
886-
// else {
887-
// oos.writeBoolean( true );
888-
// l.writeExternal( oos );
889-
// }
890-
// }
891-
// }
892-
893858
private abstract static class AbstractTransactionCompletionProcessQueue<T,U> {
894859
final ReactiveSession session;
895860

@@ -994,21 +959,6 @@ public CompletionStage<Void> afterTransactionCompletion(boolean success) {
994959
}
995960
}
996961

997-
// /**
998-
// * Wrapper class allowing to bind the same transaction completion process queues in different sessions.
999-
// */
1000-
// public static class TransactionCompletionProcesses {
1001-
// private final BeforeTransactionCompletionProcessQueue beforeTransactionCompletionProcesses;
1002-
// private final AfterTransactionCompletionProcessQueue afterTransactionCompletionProcesses;
1003-
//
1004-
// private TransactionCompletionProcesses(
1005-
// BeforeTransactionCompletionProcessQueue beforeTransactionCompletionProcessQueue,
1006-
// AfterTransactionCompletionProcessQueue afterTransactionCompletionProcessQueue) {
1007-
// this.beforeTransactionCompletionProcesses = beforeTransactionCompletionProcessQueue;
1008-
// this.afterTransactionCompletionProcesses = afterTransactionCompletionProcessQueue;
1009-
// }
1010-
// }
1011-
1012962
/**
1013963
* Order the {@link #insertions} queue such that we group inserts against the same entity together (without
1014964
* violating constraints). The original order is generated by cascade order, which in turn is based on the
@@ -1152,26 +1102,23 @@ public void sort(List<ReactiveEntityInsertActionHolder> insertions) {
11521102
*/
11531103
private void addParentChildEntityNames(ReactiveEntityInsertAction action, BatchIdentifier batchIdentifier) {
11541104
Object[] propertyValues = action.getState();
1155-
ClassMetadata classMetadata = action.getPersister().getClassMetadata();
1156-
if ( classMetadata != null ) {
1157-
Type[] propertyTypes = classMetadata.getPropertyTypes();
1158-
Type identifierType = classMetadata.getIdentifierType();
1159-
1160-
for ( int i = 0; i < propertyValues.length; i++ ) {
1161-
Object value = propertyValues[i];
1162-
if (value!=null) {
1163-
Type type = propertyTypes[i];
1164-
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, value );
1165-
}
1105+
Type[] propertyTypes = action.getPersister().getPropertyTypes();
1106+
Type identifierType = action.getPersister().getIdentifierType();
1107+
1108+
for ( int i = 0; i < propertyValues.length; i++ ) {
1109+
Object value = propertyValues[i];
1110+
if (value!=null) {
1111+
Type type = propertyTypes[i];
1112+
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, value );
11661113
}
1114+
}
11671115

1168-
if ( identifierType.isComponentType() ) {
1169-
CompositeType compositeType = (CompositeType) identifierType;
1170-
Type[] compositeIdentifierTypes = compositeType.getSubtypes();
1116+
if ( identifierType.isComponentType() ) {
1117+
CompositeType compositeType = (CompositeType) identifierType;
1118+
Type[] compositeIdentifierTypes = compositeType.getSubtypes();
11711119

1172-
for ( Type type : compositeIdentifierTypes ) {
1173-
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, null );
1174-
}
1120+
for ( Type type : compositeIdentifierTypes ) {
1121+
addParentChildEntityNameByPropertyAndValue( action, batchIdentifier, type, null );
11751122
}
11761123
}
11771124
}
@@ -1275,10 +1222,9 @@ public boolean equals(Object o) {
12751222
if ( this == o ) {
12761223
return true;
12771224
}
1278-
if ( !( o instanceof BatchIdentifier ) ) {
1225+
if ( !( o instanceof BatchIdentifier that ) ) {
12791226
return false;
12801227
}
1281-
BatchIdentifier that = (BatchIdentifier) o;
12821228
return Objects.equals( entityName, that.entityName );
12831229
}
12841230

@@ -1315,9 +1261,7 @@ boolean hasAnyChildEntityNames(BatchIdentifier batchIdentifier) {
13151261
/**
13161262
* Check if this {@link BatchIdentifier} has a parent or grandparent
13171263
* matching the given {@link BatchIdentifier reference.
1318-
*
13191264
* @param batchIdentifier {@link BatchIdentifier} reference
1320-
*
13211265
* @return this {@link BatchIdentifier} has a parent matching the given {@link BatchIdentifier reference
13221266
*/
13231267
boolean hasParent(BatchIdentifier batchIdentifier) {

0 commit comments

Comments
 (0)