Skip to content

Commit 5d58f80

Browse files
committed
[#2004] Fix support for IdClass with ManyToOne
1 parent aea61d0 commit 5d58f80

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import org.hibernate.engine.FetchTiming;
99
import org.hibernate.metamodel.mapping.NonAggregatedIdentifierMapping;
10+
import org.hibernate.metamodel.mapping.internal.ToOneAttributeMapping;
11+
import org.hibernate.reactive.metamodel.mapping.internal.ReactiveToOneAttributeMapping;
1012
import org.hibernate.reactive.sql.results.graph.entity.internal.ReactiveEntityFetchJoinedImpl;
1113
import org.hibernate.spi.NavigablePath;
1214
import org.hibernate.sql.results.graph.AssemblerCreationState;
@@ -50,8 +52,15 @@ public Fetch generateFetchableFetch(
5052
boolean selected,
5153
String resultVariable,
5254
DomainResultCreationState creationState) {
55+
// I don't think this is the right approach.
56+
// Fetchable should already be an instance of ReactiveToOneAttributeMapping
57+
// (if it's an instance of ToOneAttributeMapping). But I don't think there is a way right now
58+
// to make it happen without changing ORM.
59+
Fetchable reactiveFetchable = fetchable instanceof ToOneAttributeMapping && !( fetchable instanceof ReactiveToOneAttributeMapping )
60+
? new ReactiveToOneAttributeMapping( (ToOneAttributeMapping) fetchable )
61+
: fetchable;
5362
Fetch fetch = super.generateFetchableFetch(
54-
fetchable,
63+
reactiveFetchable,
5564
fetchablePath,
5665
fetchTiming,
5766
selected,

0 commit comments

Comments
 (0)