1 package net.sumaris.core.dao.data;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import net.sumaris.core.dao.technical.SortDirection;
26 import net.sumaris.core.dao.technical.jpa.SumarisJpaRepository;
27 import net.sumaris.core.model.data.IRootDataEntity;
28 import net.sumaris.core.vo.data.DataFetchOptions;
29 import net.sumaris.core.vo.data.IRootDataVO;
30 import net.sumaris.core.vo.filter.IRootDataFilter;
31 import org.springframework.data.domain.Example;
32 import org.springframework.data.domain.Page;
33 import org.springframework.data.domain.Pageable;
34 import org.springframework.data.jpa.domain.Specification;
35 import org.springframework.data.jpa.repository.Lock;
36 import org.springframework.data.repository.NoRepositoryBean;
37 import org.springframework.lang.Nullable;
38
39 import javax.persistence.LockModeType;
40 import java.util.List;
41
42 @NoRepositoryBean
43 public interface RootDataRepository<
44 T extends IRootDataEntity<ID>,
45 ID extends Integer,
46 V extends IRootDataVO<ID>,
47 F extends IRootDataFilter
48 >
49 extends SumarisJpaRepository<T, Integer> {
50
51 List<V> findAll(@Nullable F filter);
52
53 Page<V> findAll(@Nullable F filter, Pageable pageable);
54
55 List<V> findAll(@Nullable F filter, @Nullable DataFetchOptions fetchOptions);
56
57 Page<V> findAll(@Nullable F filter, Pageable pageable, @Nullable DataFetchOptions fetchOptions);
58
59 Page<V> findAll(int offset, int size, String sortAttribute, SortDirection sortDirection, DataFetchOptions fetchOptions);
60
61 Page<V> findAll(F filter, int offset, int size, String sortAttribute,
62 SortDirection sortDirection, DataFetchOptions fetchOptions);
63
64 List<V> findAllAsVO(@Nullable Specification<T> spec);
65 Page<V> findAllAsVO(@Nullable Specification<T> spec, Pageable pageable);
66 List<V> findAllAsVO(@Nullable Specification<T> spec, DataFetchOptions fetchOptions);
67 Page<V> findAllAsVO(@Nullable Specification<T> spec, Pageable pageable, DataFetchOptions fetchOption);
68
69 long count(F filter);
70
71 V get(int id);
72
73 V get(int id, DataFetchOptions fetchOptions);
74
75 @Lock(LockModeType.PESSIMISTIC_WRITE)
76 V save(V vo);
77
78 Specification<T> toSpecification(@Nullable F filter);
79
80 V control(V vo);
81
82 V validate(V vo);
83
84 V unvalidate(V vo);
85
86
87
88
89
90
91
92
93 }