1 package org.itracker.persistence.dao; 2 3 import org.hibernate.HibernateException; 4 import org.hibernate.criterion.Expression; 5 import org.itracker.model.Component; 6 7 import java.util.List; 8 9 public class ComponentDAOImpl extends BaseHibernateDAOImpl<Component> 10 implements ComponentDAO { 11 12 public Component findById(Integer componentId) { 13 try { 14 return (Component) getSession().get(Component.class, componentId); 15 } catch (HibernateException e) { 16 throw convertHibernateAccessException(e); 17 } 18 } 19 20 @SuppressWarnings("unchecked") 21 public List<Component> findByProject(Integer projectId) { 22 try { 23 return getSession().createCriteria(Component.class) 24 .add(Expression.eq("project.id", projectId)) 25 .list(); 26 } catch (HibernateException e) { 27 throw convertHibernateAccessException(e); 28 } 29 } 30 31 }