Skip to content

Adapt to API consolidation in Spring Data Commons' PersistentProperty. #2255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
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
Expand Down Expand Up @@ -130,10 +130,19 @@ public Class<?> getActualType() {
*/
@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();
}

/*
Expand Down Expand Up @@ -219,22 +228,22 @@ public boolean isEmbeddable() {

/*
* (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();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ void considersTargetEntityTypeForPropertyType() {
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));
Expand Down