1 package de.spring.example.persistence.repository;
3 import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
4 import org.springframework.data.jpa.repository.Query;
5 import org.springframework.data.repository.PagingAndSortingRepository;
6 import org.springframework.data.repository.history.RevisionRepository;
7 import org.springframework.data.repository.query.Param;
9 import de.spring.example.persistence.domain.Ad;
12 * By default <code>org.springframework.data.jpa.repository.support.SimpleJpaRepository<code>
13 * will be the implementation for this interface.
15 * Be careful with <code>@Transactional</code>. SimpleJpaRepository has annotated methods.
18 public interface AdRepository extends
19 PagingAndSortingRepository<Ad, Long>,
20 JpaSpecificationExecutor<Ad>,
21 RevisionRepository<Ad, Long, Integer> {
23 // Named Native Query (using the native language of the store) It is not portable.
24 // See de.spring.persistence.example.domain.Ad
25 @Query(value="SELECT * FROM ad WHERE ad.id = :id", nativeQuery=true)
26 Ad findByIdNativeQuery(@Param("id") Long id);
28 // Named Query (using JPL) It is portable.
29 // See de.spring.persistence.example.domain.Ad
30 @Query("select a from Ad a where a.id = :id")
31 Ad findByIdQuery(@Param("id") Long id);