Leonardo Vannucci
2019-04-03 84d99d0f0700b2a19f504b21b1747275251305d8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package it.digione.dg1cloud.repository;
 
import java.util.List;
 
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
 
import it.digione.dg1cloud.model.RegDocument;
 
@Repository
@Transactional( propagation = Propagation.REQUIRED )
public interface RegDocumentRepository extends JpaRepository<RegDocument, Long> {
   
   @Query("SELECT d FROM RegDocument d WHERE d.fileHash = :fileHash and d.fileName = :fileName and d.createdBy = :userName")
   RegDocument findOneByHashAndName(@Param("fileHash") String fileHash, @Param("fileName") String fileName, @Param("userName") String userName);
   
   @Query("SELECT d FROM RegDocument d WHERE CURRENT_DATE > d.dueDate")
   List<RegDocument> findAllRegDocumentExpired();
   
   @Query("SELECT d FROM RegDocument d WHERE d.customKey = :customKey")
   RegDocument findOneByCustomKey(@Param("customKey") String customKey);
}