日期:2014-05-17 浏览次数:20722 次
public class GenericDaoImpl<T, ID extends Serializable> implements
GenericDao<T, ID> {
// 具体的实体类型
private Class<T> type;
// Spring提供的Hibernate工具类
private HibernateTemplate hibernateTemplate;
// 查询条件
private String hql;
public GenericDaoImpl(Class<T> type) {
this.type = type;
this.hql = "from " + type.getName();
}
public GenericDaoImpl() {
}
@Resource
public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
this.hibernateTemplate = hibernateTemplate;
}
public HibernateTemplate getHibernateTemplate() {
return hibernateTemplate;
}
@SuppressWarnings("unchecked")
public List<T> findAll() {
String hql = "from " + type.getName();
return (List<T>) hibernateTemplate.find(hql);
}
class test.s2sh.bean.Person