1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.hack23.cia.service.data.impl;
20
21 import java.util.List;
22
23 import javax.persistence.TypedQuery;
24 import javax.persistence.criteria.CriteriaQuery;
25 import javax.persistence.criteria.Predicate;
26 import javax.persistence.criteria.Root;
27
28 import org.springframework.stereotype.Repository;
29
30 import com.hack23.cia.model.external.riksdagen.utskottsforslag.impl.CommitteeDocumentData;
31 import com.hack23.cia.model.external.riksdagen.utskottsforslag.impl.CommitteeDocumentData_;
32 import com.hack23.cia.model.external.riksdagen.utskottsforslag.impl.CommitteeProposalComponentData;
33 import com.hack23.cia.service.data.api.CommitteeProposalComponentDataDAO;
34
35
36
37
38 @Repository("CommitteeProposalComponentDataDAO")
39 final class CommitteeProposalComponentDataDAOImpl extends
40 AbstractGenericDAOImpl<CommitteeProposalComponentData, Long>
41 implements CommitteeProposalComponentDataDAO {
42
43
44
45
46 public CommitteeProposalComponentDataDAOImpl() {
47 super(CommitteeProposalComponentData.class);
48 }
49
50 @Override
51 public boolean checkCommitteeDocumentData(final String documentId) {
52 final CriteriaQuery<CommitteeDocumentData> criteriaQuery = getCriteriaBuilder()
53 .createQuery(CommitteeDocumentData.class);
54 final Root<CommitteeDocumentData> root = criteriaQuery.from(CommitteeDocumentData.class);
55 criteriaQuery.select(root);
56 final Predicate condition = getCriteriaBuilder().equal(root.get(CommitteeDocumentData_.id), documentId);
57 criteriaQuery.where(condition);
58 final TypedQuery<CommitteeDocumentData> typedQuery = getEntityManager()
59 .createQuery(criteriaQuery);
60 addCacheHints(typedQuery, "checkCommitteeDocumentData");
61
62 final List<CommitteeDocumentData> resultList = typedQuery.getResultList();
63
64 return !resultList.isEmpty();
65 }
66
67 @Override
68 public List<String> getIdList() {
69 final CriteriaQuery<String> criteria = getCriteriaBuilder().createQuery(String.class);
70 final Root<CommitteeDocumentData> root = criteria.from(CommitteeDocumentData.class);
71 criteria.select(root.get(CommitteeDocumentData_.id));
72 criteria.distinct(true);
73 return getEntityManager().createQuery(criteria).getResultList();
74 }
75
76 }