1
2
3
4
5 package org.directdemocracyportal.democracy.service.dao.hibernate;
6
7 import java.util.List;
8
9 import org.directdemocracyportal.democracy.model.world.Government;
10 import org.directdemocracyportal.democracy.model.world.OrganisationType;
11 import org.directdemocracyportal.democracy.service.dao.GovernmentDAO;
12 import org.hibernate.criterion.DetachedCriteria;
13 import org.hibernate.criterion.Restrictions;
14 import org.springframework.transaction.annotation.Propagation;
15 import org.springframework.transaction.annotation.Transactional;
16
17 /***
18 * The Class HibernateGovernmentDAO.
19 */
20 @Transactional(propagation = Propagation.MANDATORY)
21 public class HibernateGovernmentDAO extends
22 GenericHibernateDAO<Government, Long> implements GovernmentDAO
23 {
24
25 /***
26 * Instantiates a new hibernate government dao.
27 */
28 public HibernateGovernmentDAO() {
29 super(Government.class);
30 }
31
32
33
34
35
36
37 @Override
38 public List<Government> getAllNationalGovernments() {
39 DetachedCriteria findNational = DetachedCriteria
40 .forClass(Government.class);
41 findNational.add(Restrictions.eq("organisationType",
42 OrganisationType.National));
43
44 @SuppressWarnings("unchecked")
45 List<Government> result = this.getHibernateTemplate().findByCriteria(
46 findNational);
47 return result;
48 }
49
50 }