Custom Repository Base Class + QueryDslPredicateExecutor
Ich habe gefundenQueryDslPredicateExecutor
sehr nützlich zum Reduzieren von Kesselplatten, aber es scheint, als würde ein Schraubenschlüssel ins Werk geworfen. Ich versuche jetzt, @ zu verlängeJpaRepository
Mit einem benutzerdefinierten Basisklassen-Repository und beim Start hat Spring Probleme, Repositorys korrekt zu instanziieren.
//Custom base class
@NoRepositoryBean
public interface IdAwareRepository<A, ID extends Serializable> extends JpaRepository<A, ID> {
// ID getId(A a);
}
// Base class implementation
public class IdAwareRepositoryImpl<A, ID extends Serializable>
extends SimpleJpaRepository<A, ID> implements IdAwareRepository<A, ID> {
public IdAwareRepositoryImpl(JpaEntityInformation<A, ?> entityInformation, EntityManager entityManager) {
super(entityInformation, entityManager);
}
}
// Individual repo
@Repository
public interface MyPojoRepository extends JpaRepository<MyPojo, Integer>, QueryDslPredicateExecutor<MyPojo> {
}
// Spring boot main application class
@EnableJpaRepositories(repositoryBaseClass = IdAwareRepositoryImpl.class)
@EntityScan(basePackageClasses = {Application.class, Jsr310JpaConverters.class})
@EnableAutoConfiguration(exclude = {
org.springframework.boot.autoconfigure.security.SecurityAutoConfiguration.class,
org.springframework.boot.actuate.autoconfigure.ManagementWebSecurityAutoConfiguration.class})
@SpringBootApplication
public class Application {}
Ich habe verschiedene Variationen dieses Themas ausprobiert, hatte aber kein Glück, die Dinge erfolgreich zu verkabeln. Ich bin auf ein ähnliches Problem im Issue Tracker von Spring gestoßehttps: //jira.spring.io/browse/DATAJPA-67, aber keine Erklärung für das Update, nur dieser Code wurde überarbeitet, um die Arbeit zu erleichtern.
Ich erhalte den folgenden Fehler:
Ursache: org.springframework.data.mapping.PropertyReferenceException: Keine Eigenschaft findAll gefunden für Typ MyPojo! at org.springframework.data.mapping.PropertyPath. (PropertyPath.java:77) at org.springframework.data.mapping.PropertyPath.create (PropertyPath.java:329) at org.springframework.data.mapping.PropertyPath.create ( PropertyPath.java:309) unter org.springframework.data.mapping.PropertyPath.from (PropertyPath.java:272) unter org.springframework.data.mapping.PropertyPath.from (PropertyPath.java:243) unter org.springframework.data .repository.query.parser.Part. (Part.java:76) at org.springframework.data.repository.query.parser.PartTree $ OrPart. (PartTree.java:235) at org.springframework.data.repository.query .parser.PartTree $ Predicate.buildTree (PartTree.java:373) at org.springframework.data.repository.query.parser.PartTree $ Predicate. (PartTree.java:353) at org.springframework.data.repository.query. parser.PartTree. (PartTree.java:84) at org.springframework.data.jpa.repository.query.PartTreeJpaQuery. (PartTreeJpaQuery.java:62) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy $ CreateQuery ategy.resolveQuery (JpaQueryLookupStrategy.java:100) at org.springframework.data.jpa.repository.query.JpaQueryLookupStrategy $ CreateIfNotFoundQueryLookupStrategy.resolveQuery (JpaQueryLookupStrategy.java: AbstractQueryLookupStrategy.resolveQuery (JpaQueryLookupStrategy.java:74) unter org.springframework.data.repository.core.support.RepositoryFactorySupport $ QueryExecutorMethodInterceptor (RepositoryFactorySupport : 237) unter org.springframework.data.jpa.repository.support.JpaRepositoryFactoryBean.afterPropertiesSet (JpaReposito ryFactoryBean.java:92) bei org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods (AbstractAutowireCapableBeanFactory.java:1637) bei org.springframework.beans.factory.support.AbstractAutowireCapableButowi
Welche mir sagt, dass Spring nicht in der Lage ist, sowohl die benutzerdefinierte Basisklasse als auch @ zu verbindQueryDslPredicateExecutor
Erweiterungen zuJpaRepository