Adapt to API consolidation in Spring Data Commons' PersistentProperty.

Closes: #2254
Original Pull Request: #2255
Related to: spring-projects/spring-data-commons#2408
This commit is contained in:
Oliver Drotbohm
2021-07-09 15:23:23 +02:00
committed by Christoph Strobl
parent 8d6634430f
commit 400aa0e042
2 changed files with 17 additions and 8 deletions

View File

@@ -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<JpaPer
*/
@Override
public Iterable<? extends TypeInformation<?>> getPersistentEntityTypes() {
return getPersistentEntityTypeInformation();
}
/*
* (non-Javadoc)
* @see org.springframework.data.mapping.model.AbstractPersistentProperty#getPersistentEntityTypeInformation()
*/
@Override
public Iterable<? extends TypeInformation<?>> getPersistentEntityTypeInformation() {
return associationTargetType != null //
? Collections.singleton(associationTargetType) //
: super.getPersistentEntityTypes();
: super.getPersistentEntityTypeInformation();
}
/*
@@ -219,22 +228,22 @@ class JpaPersistentPropertyImpl extends AnnotationBasedPersistentProperty<JpaPer
/*
* (non-Javadoc)
* @see org.springframework.data.mapping.model.AnnotationBasedPersistentProperty#getAssociationTargetType()
* @see org.springframework.data.mapping.model.AnnotationBasedPersistentProperty#getAssociationTargetTypeInformation()
*/
@Override
public Class<?> 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();
}
/**

View File

@@ -144,7 +144,7 @@ public class JpaPersistentPropertyImplUnitTests {
assertThat(property.getType()).isEqualTo(Api.class);
assertThat(property.getActualType()).isEqualTo(Implementation.class);
Iterable<? extends TypeInformation<?>> entityType = property.getPersistentEntityTypes();
Iterable<? extends TypeInformation<?>> entityType = property.getPersistentEntityTypeInformation();
assertThat(entityType.iterator().hasNext()).isTrue();
assertThat(entityType.iterator().next())
.isEqualTo(ClassTypeInformation.from(Implementation.class));