1 package org.itracker.persistence.dao;
2
3 import org.hibernate.HibernateException;
4 import org.hibernate.criterion.Expression;
5 import org.itracker.model.Project;
6 import org.itracker.model.Version;
7
8 import java.util.List;
9
10
11
12
13 public class VersionDAOImpl extends BaseHibernateDAOImpl<Version>
14 implements VersionDAO {
15
16
17
18
19
20
21
22 public Version findByPrimaryKey(Integer versionId) {
23 try {
24 return (Version) getSession().get(Version.class, versionId);
25 } catch (HibernateException e) {
26 throw convertHibernateAccessException(e);
27 }
28 }
29
30
31
32
33
34
35
36
37 @SuppressWarnings("unchecked")
38 public List<Version> findByProjectId(Integer projectId) {
39 try {
40 Project/../../../org/itracker/model/Project.html#Project">Project project = (Project) getSession().load(Project.class, projectId);
41 return getSession().createCriteria(Version.class)
42 .add(Expression.eq("project", project))
43 .list();
44 } catch (HibernateException e) {
45 throw convertHibernateAccessException(e);
46 }
47 }
48 }