From 400aa0e042920341917d2705e79cdb2ff18bd9d7 Mon Sep 17 00:00:00 2001 From: Oliver Drotbohm Date: Fri, 9 Jul 2021 15:23:23 +0200 Subject: [PATCH] Adapt to API consolidation in Spring Data Commons' PersistentProperty. Closes: #2254 Original Pull Request: #2255 Related to: spring-projects/spring-data-commons#2408 --- .../mapping/JpaPersistentPropertyImpl.java | 23 +++++++++++++------ .../JpaPersistentPropertyImplUnitTests.java | 2 +- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java b/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java index a60b24eed..a0ac87b81 100644 --- a/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java +++ b/src/main/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImpl.java @@ -39,7 +39,7 @@ import org.springframework.lang.Nullable; import org.springframework.util.Assert; /** - * {@link JpaPersistentProperty} implementation usind a JPA {@link Metamodel}. + * {@link JpaPersistentProperty} implementation using a JPA {@link Metamodel}. * * @author Oliver Gierke * @author Thomas Darimont @@ -130,10 +130,19 @@ class JpaPersistentPropertyImpl extends AnnotationBasedPersistentProperty> getPersistentEntityTypes() { + return getPersistentEntityTypeInformation(); + } + + /* + * (non-Javadoc) + * @see org.springframework.data.mapping.model.AbstractPersistentProperty#getPersistentEntityTypeInformation() + */ + @Override + public Iterable> getPersistentEntityTypeInformation() { return associationTargetType != null // ? Collections.singleton(associationTargetType) // - : super.getPersistentEntityTypes(); + : super.getPersistentEntityTypeInformation(); } /* @@ -219,22 +228,22 @@ class JpaPersistentPropertyImpl extends AnnotationBasedPersistentProperty getAssociationTargetType() { + public TypeInformation getAssociationTargetTypeInformation() { if (!isAssociation()) { return null; } if (associationTargetType != null) { - return associationTargetType.getType(); + return associationTargetType; } - Class targetType = super.getAssociationTargetType(); + TypeInformation targetType = super.getAssociationTargetTypeInformation(); - return targetType != null ? targetType : getActualType(); + return targetType != null ? targetType : getActualTypeInformation(); } /** diff --git a/src/test/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImplUnitTests.java b/src/test/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImplUnitTests.java index 1a4f219c8..2c98720dc 100644 --- a/src/test/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImplUnitTests.java +++ b/src/test/java/org/springframework/data/jpa/mapping/JpaPersistentPropertyImplUnitTests.java @@ -144,7 +144,7 @@ public class JpaPersistentPropertyImplUnitTests { assertThat(property.getType()).isEqualTo(Api.class); assertThat(property.getActualType()).isEqualTo(Implementation.class); - Iterable> entityType = property.getPersistentEntityTypes(); + Iterable> entityType = property.getPersistentEntityTypeInformation(); assertThat(entityType.iterator().hasNext()).isTrue(); assertThat(entityType.iterator().next()) .isEqualTo(ClassTypeInformation.from(Implementation.class));