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() {
224224 @ Override
225225 public Class <?> getAssociationTargetType () {
226226
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 ();
230238 }
231239
232240 /**
Original file line number Diff line number Diff line change 4141import org .mockito .junit .jupiter .MockitoExtension ;
4242import org .mockito .junit .jupiter .MockitoSettings ;
4343import org .mockito .quality .Strictness ;
44-
4544import org .springframework .data .annotation .AccessType .Type ;
4645import org .springframework .data .annotation .Version ;
4746import org .springframework .data .util .ClassTypeInformation ;
@@ -74,7 +73,9 @@ void setUp() {
7473 void considersOneToOneMappedPropertyAnAssociation () {
7574
7675 JpaPersistentProperty property = entity .getRequiredPersistentProperty ("other" );
76+
7777 assertThat (property .isAssociation ()).isTrue ();
78+ assertThat (property .getAssociationTargetType ()).isEqualTo (Sample .class );
7879 }
7980
8081 @ Test // DATAJPA-376
@@ -146,7 +147,7 @@ void considersTargetEntityTypeForPropertyType() {
146147 Iterable <? extends TypeInformation <?>> entityType = property .getPersistentEntityTypes ();
147148 assertThat (entityType .iterator ().hasNext ()).isTrue ();
148149 assertThat (entityType .iterator ().next ())
149- .isEqualTo (( TypeInformation ) ClassTypeInformation .from (Implementation .class ));
150+ .isEqualTo (ClassTypeInformation .from (Implementation .class ));
150151 }
151152
152153 @ Test // DATAJPA-716
You can’t perform that action at this time.
0 commit comments