1
2
3
4
5
6 package com.hack23.cia.service.dao;
7
8 import org.hibernate.HibernateException;
9 import org.hibernate.criterion.Restrictions;
10 import org.springframework.transaction.annotation.Transactional;
11
12 import com.hack23.cia.model.sweden.impl.PoliticalParty;
13
14 /***
15 * The Class PoliticalPartyDAOImpl.
16 */
17 public class PoliticalPartyDAOImpl extends
18 GenericHibernateDAO<PoliticalParty, Long> implements
19 PoliticalPartyDAO {
20
21 /***
22 * Instantiates a new political party dao impl.
23 */
24 public PoliticalPartyDAOImpl() {
25 super(PoliticalParty.class);
26 }
27
28
29
30
31
32
33
34 @Override
35 @Transactional(readOnly = true)
36 public final PoliticalParty findByName(final String name) {
37 try {
38 return (PoliticalParty) getSession()
39 .createCriteria(PoliticalParty.class)
40 .add(Restrictions.eq("name", name)).setCacheable(true).uniqueResult();
41 } catch (final HibernateException hibernateException) {
42 throw getHibernateTemplate().convertHibernateAccessException(
43 hibernateException);
44 }
45 }
46
47
48
49
50 @Override
51 @Transactional(readOnly = true)
52 public final PoliticalParty findByShortCode(final String shortCode) {
53 try {
54 return (PoliticalParty) getSession()
55 .createCriteria(PoliticalParty.class)
56 .add(Restrictions.eq("shortCode", shortCode)).setCacheable(true).uniqueResult();
57 } catch (final HibernateException hibernateException) {
58 throw getHibernateTemplate().convertHibernateAccessException(
59 hibernateException);
60 }
61 }
62
63 }