From: Gustavo Martin Morcuende Date: Tue, 26 Jul 2016 17:28:25 +0000 (+0200) Subject: Spring JPA: spring-data-envers does not work yet with QueryDSL X-Git-Url: https://git.gumartinm.name/?a=commitdiff_plain;h=0e84ed93058001fbc6de3d1e9e4a7c73f50a7a74;p=JavaForFun Spring JPA: spring-data-envers does not work yet with QueryDSL See: https://github.com/spring-projects/spring-data-envers/pull/45 --- diff --git a/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java b/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java index 4b4e6fc..817884c 100644 --- a/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java +++ b/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java @@ -2,8 +2,8 @@ package de.spring.example.persistence.repository; import org.springframework.data.domain.Page; import org.springframework.data.domain.Pageable; -import org.springframework.data.querydsl.QueryDslPredicateExecutor; import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.history.RevisionRepository; import de.spring.example.persistence.domain.Ad; import de.spring.example.persistence.domain.AdDescription; @@ -15,7 +15,10 @@ import de.spring.example.persistence.domain.AdDescription; * Be careful with @Transactional. SimpleJpaRepository has annotated methods. * */ -public interface AdDescriptionRepository extends PagingAndSortingRepository, QueryDslPredicateExecutor { +public interface AdDescriptionRepository extends + PagingAndSortingRepository, + /** https://github.com/spring-projects/spring-data-envers/pull/45 QueryDslPredicateExecutor, **/ + RevisionRepository { // Custom Query method (useful when the offered methods by PagingAndSortingRepository are not enough) Page findByAd(Ad ad, Pageable pageable); diff --git a/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdRepository.java b/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdRepository.java index bc73359..c0add01 100644 --- a/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdRepository.java +++ b/SpringJava/JPA/spring-jpa-persistence/src/main/java/de/spring/example/persistence/repository/AdRepository.java @@ -3,6 +3,7 @@ package de.spring.example.persistence.repository; import org.springframework.data.jpa.repository.JpaSpecificationExecutor; import org.springframework.data.jpa.repository.Query; import org.springframework.data.repository.PagingAndSortingRepository; +import org.springframework.data.repository.history.RevisionRepository; import org.springframework.data.repository.query.Param; import de.spring.example.persistence.domain.Ad; @@ -14,7 +15,10 @@ import de.spring.example.persistence.domain.Ad; * Be careful with @Transactional. SimpleJpaRepository has annotated methods. * */ -public interface AdRepository extends PagingAndSortingRepository, JpaSpecificationExecutor { +public interface AdRepository extends + PagingAndSortingRepository, + JpaSpecificationExecutor, + RevisionRepository { // Named Native Query (using the native language of the store) It is not portable. // See de.spring.persistence.example.domain.Ad diff --git a/SpringJava/JPA/spring-jpa-persistence/src/main/resources/spring-configuration/jpa-configuration.xml b/SpringJava/JPA/spring-jpa-persistence/src/main/resources/spring-configuration/jpa-configuration.xml index 5c95de1..bcdd8a3 100644 --- a/SpringJava/JPA/spring-jpa-persistence/src/main/resources/spring-configuration/jpa-configuration.xml +++ b/SpringJava/JPA/spring-jpa-persistence/src/main/resources/spring-configuration/jpa-configuration.xml @@ -16,6 +16,11 @@ + + @@ -48,8 +53,6 @@ - + diff --git a/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdDescriptionServiceImpl.java b/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdDescriptionServiceImpl.java index 7f5a681..830709b 100644 --- a/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdDescriptionServiceImpl.java +++ b/SpringJava/JPA/spring-jpa-services/src/main/java/de/spring/example/services/impl/AdDescriptionServiceImpl.java @@ -45,7 +45,10 @@ public class AdDescriptionServiceImpl final QAdDescription adDescription = QAdDescription.adDescription1; final BooleanExpression adDescriptionHasAdLink = adDescription.adLink.contains("gumartinm"); final BooleanExpression adDescriptionHasDescription = adDescription.adDescription.contains("babucha"); - - return repository.findAll(adDescriptionHasAdLink.and(adDescriptionHasDescription), pageRequest); + /** + * https://github.com/spring-projects/spring-data-envers/pull/45 + * return repository.findAll(adDescriptionHasAdLink.and(adDescriptionHasDescription), pageRequest); + */ + return null; } }