Skip to content
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 @@ -25,7 +25,6 @@
import org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean;
import org.springframework.data.repository.core.RepositoryMetadata;
import org.springframework.data.repository.core.support.RepositoryComposition.RepositoryFragments;
import org.springframework.data.repository.core.support.RepositoryFactorySupport;
import org.springframework.data.repository.history.RevisionRepository;
import org.springframework.data.repository.history.support.RevisionEntityInformation;

Expand Down Expand Up @@ -59,7 +58,7 @@ public void setRevisionEntityClass(Class<?> revisionEntityClass) {
}

@Override
protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) {
protected JpaRepositoryFactory createJpaRepositoryFactory(EntityManager entityManager){
return new RevisionRepositoryFactory<T, ID, N>(entityManager, revisionEntityClass);
}

Expand All @@ -72,7 +71,6 @@ protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityM
private static class RevisionRepositoryFactory<T, ID, N extends Number & Comparable<N>> extends JpaRepositoryFactory {

private final RevisionEntityInformation revisionEntityInformation;
private final EntityManager entityManager;

/**
* Creates a new {@link RevisionRepositoryFactory} using the given {@link EntityManager} and revision entity class.
Expand All @@ -84,7 +82,6 @@ public RevisionRepositoryFactory(EntityManager entityManager, Class<?> revisionE

super(entityManager);

this.entityManager = entityManager;
this.revisionEntityInformation = Optional.ofNullable(revisionEntityClass) //
.filter(it -> !it.equals(DefaultRevisionEntity.class))//
.<RevisionEntityInformation> map(ReflectionRevisionEntityInformation::new) //
Expand All @@ -98,7 +95,7 @@ protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata
EnversRevisionRepositoryImpl.class, //
getEntityInformation(metadata.getDomainType()), //
revisionEntityInformation, //
entityManager //
getEntityManager() //
);

return RepositoryFragments //
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,41 @@ protected RepositoryFragments getRepositoryFragments(RepositoryMetadata metadata
return RepositoryFragments.empty();
}

private void invokeAwareMethods(JpaRepositoryConfigurationAware repository) {
protected void invokeAwareMethods(JpaRepositoryConfigurationAware repository) {

repository.setRepositoryMethodMetadata(crudMethodMetadata);
repository.setEscapeCharacter(escapeCharacter);
repository.setProjectionFactory(getProjectionFactory());
}

protected EntityManager getEntityManager() {
return entityManager;
}

protected QueryExtractor getExtractor() {
return extractor;
}

protected CrudMethodMetadata getCrudMethodMetadata() {
return crudMethodMetadata;
}

protected EntityPathResolver getEntityPathResolver() {
return entityPathResolver;
}

protected EscapeCharacter getEscapeCharacter() {
return escapeCharacter;
}

protected JpaQueryMethodFactory getQueryMethodFactory() {
return queryMethodFactory;
}

protected QueryRewriterProvider getQueryRewriterProvider() {
return queryRewriterProvider;
}

private static boolean isTransactionNeeded(Class<?> repositoryClass) {

Method[] methods = ReflectionUtils.getAllDeclaredMethods(repositoryClass);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected RepositoryFactorySupport doCreateRepositoryFactory() {
*/
protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityManager) {

JpaRepositoryFactory jpaRepositoryFactory = new JpaRepositoryFactory(entityManager);
JpaRepositoryFactory jpaRepositoryFactory = createJpaRepositoryFactory(entityManager);
jpaRepositoryFactory.setEntityPathResolver(entityPathResolver);
jpaRepositoryFactory.setEscapeCharacter(escapeCharacter);

Expand All @@ -124,6 +124,11 @@ protected RepositoryFactorySupport createRepositoryFactory(EntityManager entityM
return jpaRepositoryFactory;
}

protected JpaRepositoryFactory createJpaRepositoryFactory(EntityManager entityManager) {

return new JpaRepositoryFactory(entityManager);
}

@Override
public void afterPropertiesSet() {

Expand All @@ -136,4 +141,21 @@ public void setEscapeCharacter(char escapeCharacter) {

this.escapeCharacter = EscapeCharacter.of(escapeCharacter);
}

@Nullable
protected EntityManager getEntityManager() {
return entityManager;
}

protected EntityPathResolver getEntityPathResolver() {
return entityPathResolver;
}

protected EscapeCharacter getEscapeCharacter() {
return escapeCharacter;
}

protected JpaQueryMethodFactory getQueryMethodFactory() {
return queryMethodFactory;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,27 @@ protected JPQLQuery<?> createCountQuery(@Nullable Predicate... predicate) {
return doCreateQuery(getQueryHintsForCount(), predicate);
}

protected JpaEntityInformation<T, ?> getEntityInformation() {
return entityInformation;
}

protected EntityPath<T> getPath() {
return path;
}

protected Querydsl getQuerydsl() {
return querydsl;
}

protected EntityManager getEntityManager() {
return entityManager;
}

@Nullable
public CrudMethodMetadata getMetadata() {
return metadata;
}

@Nullable
private CrudMethodMetadata getRepositoryMethodMetadata() {
return metadata;
Expand Down