Skip to content

Commit a5352da

Browse files
committed
Move off deprecated RepositoryFactorySupport.getEntityInformation(Class) method.
EntityInformation is typically obtained in the context of RepositoryMetadata, hence aligning with deprecations in commons. Closes #3010
1 parent c87e0cf commit a5352da

File tree

4 files changed

+16
-16
lines changed

4 files changed

+16
-16
lines changed

src/main/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactory.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -62,18 +62,17 @@ final class Neo4jRepositoryFactory extends RepositoryFactorySupport {
6262
this.mappingContext = mappingContext;
6363
}
6464

65-
@SuppressWarnings("unchecked")
6665
@Override
67-
public <T, ID> Neo4jEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
66+
public Neo4jEntityInformation<?, ?> getEntityInformation(RepositoryMetadata metadata) {
6867

69-
Neo4jPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(domainClass);
70-
return new DefaultNeo4jEntityInformation<>((Neo4jPersistentEntity<T>) entity);
68+
Neo4jPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(metadata.getDomainType());
69+
return new DefaultNeo4jEntityInformation<>(entity);
7170
}
7271

7372
@Override
7473
protected Object getTargetRepository(RepositoryInformation metadata) {
7574

76-
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
75+
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
7776
Neo4jRepositoryFactorySupport.assertIdentifierType(metadata.getIdType(), entityInformation.getIdType());
7877
return getTargetRepositoryViaReflection(metadata, neo4jOperations, entityInformation);
7978
}
@@ -106,15 +105,15 @@ protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata
106105

107106
private RepositoryFragment<Object> createDSLPredicateExecutorFragment(RepositoryMetadata metadata, Class<?> implementor) {
108107

109-
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
108+
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
110109
Object querydslFragment = instantiateClass(implementor, mappingContext, entityInformation, neo4jOperations);
111110

112111
return RepositoryFragment.implemented(querydslFragment);
113112
}
114113

115114
private RepositoryFragment<Object> createDSLExecutorFragment(RepositoryMetadata metadata, Class<?> implementor) {
116115

117-
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
116+
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
118117
Object querydslFragment = instantiateClass(implementor, entityInformation, neo4jOperations);
119118

120119
return RepositoryFragment.implemented(querydslFragment);

src/main/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactory.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,17 @@ final class ReactiveNeo4jRepositoryFactory extends ReactiveRepositoryFactorySupp
6464
this.mappingContext = mappingContext;
6565
}
6666

67-
@SuppressWarnings("unchecked")
6867
@Override
69-
public <T, ID> Neo4jEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
68+
public Neo4jEntityInformation<?, ?> getEntityInformation(RepositoryMetadata metadata) {
7069

71-
Neo4jPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(domainClass);
72-
return new DefaultNeo4jEntityInformation<>((Neo4jPersistentEntity<T>) entity);
70+
Neo4jPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(metadata.getDomainType());
71+
return new DefaultNeo4jEntityInformation<>(entity);
7372
}
7473

7574
@Override
7675
protected Object getTargetRepository(RepositoryInformation metadata) {
7776

78-
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
77+
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
7978
Neo4jRepositoryFactorySupport.assertIdentifierType(metadata.getIdType(), entityInformation.getIdType());
8079
return getTargetRepositoryViaReflection(metadata, neo4jOperations, entityInformation);
8180
}
@@ -108,15 +107,15 @@ protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata
108107

109108
private RepositoryFragment<Object> createDSLPredicateExecutorFragment(RepositoryMetadata metadata, Class<?> implementor) {
110109

111-
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
110+
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
112111
Object querydslFragment = instantiateClass(implementor, mappingContext, entityInformation, neo4jOperations);
113112

114113
return RepositoryFragment.implemented(querydslFragment);
115114
}
116115

117116
private RepositoryFragment<Object> createDSLExecutorFragment(RepositoryMetadata metadata, Class<?> implementor) {
118117

119-
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
118+
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
120119
Object querydslFragment = instantiateClass(implementor, entityInformation, neo4jOperations);
121120

122121
return RepositoryFragment.implemented(querydslFragment);

src/test/java/org/springframework/data/neo4j/repository/support/Neo4jRepositoryFactoryTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCompositeProperties;
4343
import org.springframework.data.neo4j.repository.Neo4jRepository;
4444
import org.springframework.data.repository.core.RepositoryInformation;
45+
import org.springframework.data.repository.core.RepositoryMetadata;
4546
import org.springframework.data.repository.query.QueryCreationException;
4647

4748
/**
@@ -67,7 +68,7 @@ void setup() {
6768
metadata = mock(RepositoryInformation.class);
6869
entityInformation = mock(Neo4jEntityInformation.class);
6970

70-
doReturn(entityInformation).when(neo4jRepositoryFactory).getEntityInformation(Mockito.any());
71+
doReturn(entityInformation).when(neo4jRepositoryFactory).getEntityInformation(Mockito.any(RepositoryMetadata.class));
7172
}
7273

7374
@Test

src/test/java/org/springframework/data/neo4j/repository/support/ReactiveNeo4jRepositoryFactoryTest.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.mockito.Spy;
2929
import org.mockito.junit.jupiter.MockitoExtension;
3030
import org.springframework.data.repository.core.RepositoryInformation;
31+
import org.springframework.data.repository.core.RepositoryMetadata;
3132

3233
/**
3334
* @author Gerrit Meier
@@ -53,7 +54,7 @@ void setup() {
5354
metadata = mock(RepositoryInformation.class);
5455
entityInformation = mock(Neo4jEntityInformation.class);
5556

56-
doReturn(entityInformation).when(neo4jRepositoryFactory).getEntityInformation(Mockito.any());
57+
doReturn(entityInformation).when(neo4jRepositoryFactory).getEntityInformation(Mockito.any(RepositoryMetadata.class));
5758
}
5859

5960
@Test

0 commit comments

Comments
 (0)