Skip to content

DATACMNS-1161 - Rename PersistentProperty.getPersistentEntityType() to a plural name since it returns an Iterable. #243

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 2 commits 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
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>org.springframework.data</groupId>
<artifactId>spring-data-commons</artifactId>
<version>2.0.0.BUILD-SNAPSHOT</version>
<version>2.0.0.DATACMNS-1161-SNAPSHOT</version>

<name>Spring Data Core</name>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
* @author Jon Brisbin
* @author Oliver Gierke
* @author Mark Paluch
* @author Jens Schauder
*/
public interface PersistentProperty<P extends PersistentProperty<P>> {

Expand Down Expand Up @@ -66,10 +67,22 @@ public interface PersistentProperty<P extends PersistentProperty<P>> {
* {@literal null} in case it refers to a simple type. Will return {@link Collection}'s component type or the
* {@link Map}'s value type transparently.
*
* @return
* @Deprecated Use getPersistentEntityTypes instead.
*/
@Deprecated
Iterable<? extends TypeInformation<?>> getPersistentEntityType();

/**
* Returns the {@link TypeInformation} if the property references a {@link PersistentEntity}. Will return
* {@literal null} in case it refers to a simple type. Will return {@link Collection}'s component type or the
* {@link Map}'s value type transparently.
*
* @return
*/
default Iterable<? extends TypeInformation<?>> getPersistentEntityTypes() {
return getPersistentEntityType();
};

/**
* Returns the getter method to access the property value if available. Might return {@literal null} in case there is
* no getter method with a return type assignable to the actual property's type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ private void createAndRegisterProperty(Property input) {
return;
}

property.getPersistentEntityType().forEach(AbstractMappingContext.this::addPersistentEntity);
property.getPersistentEntityTypes().forEach(AbstractMappingContext.this::addPersistentEntity);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ public TypeInformation<?> getTypeInformation() {
* (non-Javadoc)
* @see org.springframework.data.mapping.PersistentProperty#getPersistentEntityType()
*/
@Deprecated
@Override
public Iterable<? extends TypeInformation<?>> getPersistentEntityType() {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected T createPersistentProperty(Property property, BasicPersistentEntity<Ob

when(prop.getTypeInformation()).thenReturn(owner.getTypeInformation());
when(prop.getName()).thenReturn(property.getName());
when(prop.getPersistentEntityType()).thenReturn(Collections.EMPTY_SET);
when(prop.getPersistentEntityTypes()).thenReturn(Collections.EMPTY_SET);

try {
Thread.sleep(200);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
*
* @author Oliver Gierke
* @author Christoph Strobl
* @author Jens Schauder
*/
public class AbstractPersistentPropertyUnitTests {

Expand All @@ -66,6 +67,7 @@ public void discoversComponentTypeCorrectly() throws Exception {

@Test // DATACMNS-101
public void returnsNestedEntityTypeCorrectly() {
assertThat(getProperty(TestClassComplex.class, "testClassSet").getPersistentEntityTypes()).isEmpty();
assertThat(getProperty(TestClassComplex.class, "testClassSet").getPersistentEntityType()).isEmpty();
}

Expand Down Expand Up @@ -189,6 +191,7 @@ public void considersCollectionPropertySimpleIfComponentTypeIsSimple() {
public void doesNotConsiderPropertyWithTreeMapMapValueAnEntity() {

SamplePersistentProperty property = getProperty(TreeMapWrapper.class, "map");
assertThat(property.getPersistentEntityTypes()).isEmpty();
assertThat(property.getPersistentEntityType()).isEmpty();
assertThat(property.isEntity()).isFalse();
}
Expand Down