Skip to content

Commit bc7144c

Browse files
committed
[hibernate#2026] Fix EntityTypes#loadByUniqueKey
It's using a `.thenApply` instead of a `.thenCompose`.
1 parent 8683fcb commit bc7144c

File tree

1 file changed

+7
-40
lines changed
  • hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl

1 file changed

+7
-40
lines changed

hibernate-reactive-core/src/main/java/org/hibernate/reactive/engine/impl/EntityTypes.java

+7-40
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ static CompletionStage<Object> loadByUniqueKey(
138138
else {
139139
return persister
140140
.reactiveLoadByUniqueKey( uniqueKeyPropertyName, key, session )
141-
.thenApply( ukResult -> loadHibernateProxyEntity( ukResult, session )
141+
.thenCompose( ukResult -> loadHibernateProxyEntity( ukResult, session )
142142
.thenApply( targetUK -> {
143143
persistenceContext.addEntity( euk, targetUK );
144144
return targetUK;
@@ -364,9 +364,9 @@ private static CompletionStage<Object> getIdentifierFromHibernateProxy(
364364
if ( type.isEntityIdentifierMapping() ) {
365365
propertyValue = getIdentifier( (EntityType) type, propertyValue, (SessionImplementor) session );
366366
}
367-
return completedFuture( propertyValue );
367+
return propertyValue;
368368
}
369-
return nullFuture();
369+
return null;
370370
} );
371371
}
372372

@@ -409,15 +409,7 @@ else if ( types[i] instanceof CollectionType ) {
409409
session,
410410
owner,
411411
copyCache
412-
).thenCompose( copy -> {
413-
if ( copy instanceof CompletionStage ) {
414-
return ( (CompletionStage<?>) copy ).thenAccept( nonStageCopy -> copied[i] = nonStageCopy );
415-
}
416-
else {
417-
copied[i] = copy;
418-
return voidFuture();
419-
}
420-
} );
412+
).thenAccept( copy -> copied[i] = copy );
421413
}
422414
else if ( types[i] instanceof EntityType ) {
423415
return replace(
@@ -427,16 +419,7 @@ else if ( types[i] instanceof EntityType ) {
427419
session,
428420
owner,
429421
copyCache
430-
).thenCompose( copy -> {
431-
if ( copy instanceof CompletionStage ) {
432-
return ( (CompletionStage<?>) copy )
433-
.thenAccept( nonStageCopy -> copied[i] = nonStageCopy );
434-
}
435-
else {
436-
copied[i] = copy;
437-
return voidFuture();
438-
}
439-
} );
422+
).thenAccept( copy -> copied[i] = copy );
440423
}
441424
else {
442425
final Type type = types[i];
@@ -474,15 +457,7 @@ else if ( types[i] instanceof CollectionType ) {
474457
owner,
475458
copyCache,
476459
foreignKeyDirection
477-
).thenCompose( copy -> {
478-
if ( copy instanceof CompletionStage ) {
479-
return ( (CompletionStage<?>) copy ).thenAccept( nonStageCopy -> copied[i] = nonStageCopy );
480-
}
481-
else {
482-
copied[i] = copy;
483-
return voidFuture();
484-
}
485-
} );
460+
).thenAccept( copy -> copied[i] = copy );
486461
}
487462
else if ( types[i] instanceof EntityType ) {
488463
return replace(
@@ -493,15 +468,7 @@ else if ( types[i] instanceof EntityType ) {
493468
owner,
494469
copyCache,
495470
foreignKeyDirection
496-
).thenCompose( copy -> {
497-
if ( copy instanceof CompletionStage ) {
498-
return ( (CompletionStage<?>) copy ).thenAccept( nonStageCopy -> copied[i] = nonStageCopy );
499-
}
500-
else {
501-
copied[i] = copy;
502-
return voidFuture();
503-
}
504-
} );
471+
).thenAccept( copy -> copied[i] = copy );
505472
}
506473
else {
507474
copied[i] = types[i].replace(

0 commit comments

Comments
 (0)