Move off deprecated RepositoryFactorySupport.getEntityInformation(Class) method.
EntityInformation is typically obtained in the context of RepositoryMetadata, hence aligning with deprecations in commons. Closes #3010
This commit is contained in:
@@ -62,18 +62,17 @@ final class Neo4jRepositoryFactory extends RepositoryFactorySupport {
|
||||
this.mappingContext = mappingContext;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T, ID> Neo4jEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
public Neo4jEntityInformation<?, ?> getEntityInformation(RepositoryMetadata metadata) {
|
||||
|
||||
Neo4jPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(domainClass);
|
||||
return new DefaultNeo4jEntityInformation<>((Neo4jPersistentEntity<T>) entity);
|
||||
Neo4jPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(metadata.getDomainType());
|
||||
return new DefaultNeo4jEntityInformation<>(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getTargetRepository(RepositoryInformation metadata) {
|
||||
|
||||
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
|
||||
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
|
||||
Neo4jRepositoryFactorySupport.assertIdentifierType(metadata.getIdType(), entityInformation.getIdType());
|
||||
return getTargetRepositoryViaReflection(metadata, neo4jOperations, entityInformation);
|
||||
}
|
||||
@@ -106,7 +105,7 @@ final class Neo4jRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
private RepositoryFragment<Object> createDSLPredicateExecutorFragment(RepositoryMetadata metadata, Class<?> implementor) {
|
||||
|
||||
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
|
||||
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
|
||||
Object querydslFragment = instantiateClass(implementor, mappingContext, entityInformation, neo4jOperations);
|
||||
|
||||
return RepositoryFragment.implemented(querydslFragment);
|
||||
@@ -114,7 +113,7 @@ final class Neo4jRepositoryFactory extends RepositoryFactorySupport {
|
||||
|
||||
private RepositoryFragment<Object> createDSLExecutorFragment(RepositoryMetadata metadata, Class<?> implementor) {
|
||||
|
||||
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
|
||||
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
|
||||
Object querydslFragment = instantiateClass(implementor, entityInformation, neo4jOperations);
|
||||
|
||||
return RepositoryFragment.implemented(querydslFragment);
|
||||
|
||||
@@ -64,18 +64,17 @@ final class ReactiveNeo4jRepositoryFactory extends ReactiveRepositoryFactorySupp
|
||||
this.mappingContext = mappingContext;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public <T, ID> Neo4jEntityInformation<T, ID> getEntityInformation(Class<T> domainClass) {
|
||||
public Neo4jEntityInformation<?, ?> getEntityInformation(RepositoryMetadata metadata) {
|
||||
|
||||
Neo4jPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(domainClass);
|
||||
return new DefaultNeo4jEntityInformation<>((Neo4jPersistentEntity<T>) entity);
|
||||
Neo4jPersistentEntity<?> entity = mappingContext.getRequiredPersistentEntity(metadata.getDomainType());
|
||||
return new DefaultNeo4jEntityInformation<>(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getTargetRepository(RepositoryInformation metadata) {
|
||||
|
||||
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
|
||||
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
|
||||
Neo4jRepositoryFactorySupport.assertIdentifierType(metadata.getIdType(), entityInformation.getIdType());
|
||||
return getTargetRepositoryViaReflection(metadata, neo4jOperations, entityInformation);
|
||||
}
|
||||
@@ -108,7 +107,7 @@ final class ReactiveNeo4jRepositoryFactory extends ReactiveRepositoryFactorySupp
|
||||
|
||||
private RepositoryFragment<Object> createDSLPredicateExecutorFragment(RepositoryMetadata metadata, Class<?> implementor) {
|
||||
|
||||
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
|
||||
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
|
||||
Object querydslFragment = instantiateClass(implementor, mappingContext, entityInformation, neo4jOperations);
|
||||
|
||||
return RepositoryFragment.implemented(querydslFragment);
|
||||
@@ -116,7 +115,7 @@ final class ReactiveNeo4jRepositoryFactory extends ReactiveRepositoryFactorySupp
|
||||
|
||||
private RepositoryFragment<Object> createDSLExecutorFragment(RepositoryMetadata metadata, Class<?> implementor) {
|
||||
|
||||
Neo4jEntityInformation<?, Object> entityInformation = getEntityInformation(metadata.getDomainType());
|
||||
Neo4jEntityInformation<?, ?> entityInformation = getEntityInformation(metadata);
|
||||
Object querydslFragment = instantiateClass(implementor, entityInformation, neo4jOperations);
|
||||
|
||||
return RepositoryFragment.implemented(querydslFragment);
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.springframework.data.neo4j.integration.shared.common.ThingWithAllCyph
|
||||
import org.springframework.data.neo4j.integration.shared.conversion.ThingWithCompositeProperties;
|
||||
import org.springframework.data.neo4j.repository.Neo4jRepository;
|
||||
import org.springframework.data.repository.core.RepositoryInformation;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
import org.springframework.data.repository.query.QueryCreationException;
|
||||
|
||||
/**
|
||||
@@ -67,7 +68,7 @@ class Neo4jRepositoryFactoryTest {
|
||||
metadata = mock(RepositoryInformation.class);
|
||||
entityInformation = mock(Neo4jEntityInformation.class);
|
||||
|
||||
doReturn(entityInformation).when(neo4jRepositoryFactory).getEntityInformation(Mockito.any());
|
||||
doReturn(entityInformation).when(neo4jRepositoryFactory).getEntityInformation(Mockito.any(RepositoryMetadata.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.mockito.Mockito;
|
||||
import org.mockito.Spy;
|
||||
import org.mockito.junit.jupiter.MockitoExtension;
|
||||
import org.springframework.data.repository.core.RepositoryInformation;
|
||||
import org.springframework.data.repository.core.RepositoryMetadata;
|
||||
|
||||
/**
|
||||
* @author Gerrit Meier
|
||||
@@ -53,7 +54,7 @@ class ReactiveNeo4jRepositoryFactoryTest {
|
||||
metadata = mock(RepositoryInformation.class);
|
||||
entityInformation = mock(Neo4jEntityInformation.class);
|
||||
|
||||
doReturn(entityInformation).when(neo4jRepositoryFactory).getEntityInformation(Mockito.any());
|
||||
doReturn(entityInformation).when(neo4jRepositoryFactory).getEntityInformation(Mockito.any(RepositoryMetadata.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user