1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.promotego.dao.hibernate;
20
21 import java.util.List;
22
23 import org.promotego.beans.ValidationRecord;
24 import org.promotego.dao.interfaces.ValidationRecordDao;
25 import org.springframework.orm.hibernate3.HibernateTemplate;
26
27 public class HibernateValidationRecordDao extends HibernateDaoSupport<ValidationRecord> implements ValidationRecordDao
28 {
29 public String getFindAllQuery() { return "From ValidationRecord"; }
30 public String getIdQuery() { return "From ValidationRecord where id=?"; }
31 public String getCountQuery() { return "Select count(*) from ValidationRecord"; }
32
33 public ValidationRecord getRecordByValidationKey(String validationKey)
34 {
35 HibernateTemplate ht = getHibernateTemplate();
36
37 @SuppressWarnings("unchecked")
38 List<ValidationRecord> foundRecords = ht.find("From ValidationRecord where validationKey=?", validationKey);
39
40 assert foundRecords.size() < 2 : "ValidationKey column is not unique";
41
42 if (foundRecords.size() == 0)
43 {
44 return null;
45 }
46 else
47 {
48 return foundRecords.get(0);
49 }
50 }
51 }