Skip to content

Commit 341dee3

Browse files
dreab8DavideD
authored andcommitted
[#2284] ClassCastException with MapsId, EmbeddedId, and many-to-one
1 parent 5e645e1 commit 341dee3

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/sql/results/graph/embeddable/internal/ReactiveEmbeddableFetchImpl.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public Fetch findFetch(Fetchable fetchable) {
5757
if ( fetch instanceof EntityFetchSelectImpl entityFetchSelect ) {
5858
return new ReactiveEntityFetchSelectImpl( entityFetchSelect );
5959
}
60+
else if ( fetch instanceof EmbeddableFetchImpl embeddableFetch ) {
61+
return new ReactiveEmbeddableFetchImpl( embeddableFetch );
62+
}
6063
return fetch;
6164
}
6265
}

hibernate-reactive-core/src/main/java/org/hibernate/reactive/sql/results/graph/embeddable/internal/ReactiveEmbeddableInitializerImpl.java

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -214,16 +214,21 @@ public CompletionStage<Void> forEachReactiveSubInitializer(
214214
final ReactiveEmbeddableInitializerData embeddableInitializerData = (ReactiveEmbeddableInitializerData) data;
215215
final RowProcessingState rowProcessingState = embeddableInitializerData.getRowProcessingState();
216216
if ( embeddableInitializerData.getConcreteEmbeddableType() == null ) {
217-
return loop( subInitializers, subInitializer -> loop( subInitializer, initializer -> consumer
218-
.apply( (ReactiveInitializer<?>) initializer, rowProcessingState )
219-
) );
217+
return loop( subInitializers, subInitializer ->
218+
loop( subInitializer, initializer ->
219+
initializer != null
220+
? consumer.apply( (ReactiveInitializer<?>) initializer, rowProcessingState )
221+
: voidFuture()
222+
)
223+
);
220224
}
221225
else {
222226
Initializer<InitializerData>[] initializers = subInitializers[embeddableInitializerData.getSubclassId()];
223-
return loop( 0, initializers.length, i -> {
224-
ReactiveInitializer<?> reactiveInitializer = (ReactiveInitializer<?>) initializers[i];
225-
return consumer.apply( reactiveInitializer, rowProcessingState );
226-
} );
227+
return loop(0, initializers.length, i ->
228+
initializers[i] != null
229+
? consumer.apply( (ReactiveInitializer<?>) initializers[i], rowProcessingState )
230+
: voidFuture()
231+
);
227232
}
228233
}
229234

0 commit comments

Comments
 (0)