File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
main/java/org/springframework/data/jpa/mapping
test/java/org/springframework/data/jpa/mapping Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -224,9 +224,17 @@ public boolean isEmbeddable() {
224
224
@ Override
225
225
public Class <?> getAssociationTargetType () {
226
226
227
- return associationTargetType != null //
228
- ? associationTargetType .getType () //
229
- : super .getAssociationTargetType ();
227
+ if (!isAssociation ()) {
228
+ return null ;
229
+ }
230
+
231
+ if (associationTargetType != null ) {
232
+ return associationTargetType .getType ();
233
+ }
234
+
235
+ Class <?> targetType = super .getAssociationTargetType ();
236
+
237
+ return targetType != null ? targetType : getActualType ();
230
238
}
231
239
232
240
/**
Original file line number Diff line number Diff line change 41
41
import org .mockito .junit .jupiter .MockitoExtension ;
42
42
import org .mockito .junit .jupiter .MockitoSettings ;
43
43
import org .mockito .quality .Strictness ;
44
-
45
44
import org .springframework .data .annotation .AccessType .Type ;
46
45
import org .springframework .data .annotation .Version ;
47
46
import org .springframework .data .util .ClassTypeInformation ;
@@ -74,7 +73,9 @@ void setUp() {
74
73
void considersOneToOneMappedPropertyAnAssociation () {
75
74
76
75
JpaPersistentProperty property = entity .getRequiredPersistentProperty ("other" );
76
+
77
77
assertThat (property .isAssociation ()).isTrue ();
78
+ assertThat (property .getAssociationTargetType ()).isEqualTo (Sample .class );
78
79
}
79
80
80
81
@ Test // DATAJPA-376
@@ -146,7 +147,7 @@ void considersTargetEntityTypeForPropertyType() {
146
147
Iterable <? extends TypeInformation <?>> entityType = property .getPersistentEntityTypes ();
147
148
assertThat (entityType .iterator ().hasNext ()).isTrue ();
148
149
assertThat (entityType .iterator ().next ())
149
- .isEqualTo (( TypeInformation ) ClassTypeInformation .from (Implementation .class ));
150
+ .isEqualTo (ClassTypeInformation .from (Implementation .class ));
150
151
}
151
152
152
153
@ Test // DATAJPA-716
You can’t perform that action at this time.
0 commit comments