From 1c5adcf2124f648d1df1845773dc6c3f63f0a85e Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Sun, 3 Jul 2016 20:10:38 +0200 Subject: [PATCH] Spring JPA: org.springframework.data.jpa.repository.support.SimpleJpaRepository is the default implementation for any Spring repository. SimpleJpaRepository annotates methods with @Transactional --- .../example/persistence/repository/AdDescriptionRepository.java | 7 +++++++ .../de/spring/example/persistence/repository/AdRepository.java | 7 +++++++ .../main/java/de/spring/example/rest/controllers/AdController.java | 4 ++++ 3 files changed, 18 insertions(+) diff --git a/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java b/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java index 8116883..183ae4d 100644 --- a/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java +++ b/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdDescriptionRepository.java @@ -7,6 +7,13 @@ import org.springframework.data.repository.PagingAndSortingRepository; import de.spring.example.persistence.domain.Ad; import de.spring.example.persistence.domain.AdDescription; +/** + * By default org.springframework.data.jpa.repository.support.SimpleJpaRepository + * will be the implementation for this interface. + * + * Be careful with @Transactional. SimpleJpaRepository has annotated methods. + * + */ public interface AdDescriptionRepository extends PagingAndSortingRepository { // Custom Query method diff --git a/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdRepository.java b/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdRepository.java index a9b204f..592e241 100644 --- a/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdRepository.java +++ b/SpringJava/JPA/src/main/java/de/spring/example/persistence/repository/AdRepository.java @@ -6,6 +6,13 @@ import org.springframework.data.repository.query.Param; import de.spring.example.persistence.domain.Ad; +/** + * By default org.springframework.data.jpa.repository.support.SimpleJpaRepository + * will be the implementation for this interface. + * + * Be careful with @Transactional. SimpleJpaRepository has annotated methods. + * + */ public interface AdRepository extends PagingAndSortingRepository { // Named Native Query (using the native language of the store) It is not portable. diff --git a/SpringJava/JPA/src/main/java/de/spring/example/rest/controllers/AdController.java b/SpringJava/JPA/src/main/java/de/spring/example/rest/controllers/AdController.java index 976a1df..edbf37d 100644 --- a/SpringJava/JPA/src/main/java/de/spring/example/rest/controllers/AdController.java +++ b/SpringJava/JPA/src/main/java/de/spring/example/rest/controllers/AdController.java @@ -20,4 +20,8 @@ public class AdController extends RepositoryBasedRestController