这段代码有什么问题,HibernateDaoSupport的方法全部报错 50
packagedao.impl;importjava.util.List;importorg.hibernate.Query;importorg.springframew...
package dao.impl;
import java.util.List;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import dao.IDao;
public class DaoImpl<T> extends HibernateDaoSupport implements IDao<T> {
@SuppressWarnings("unchecked")
public T find(Class<T> clazz, int id){
return(T) getHibernateTemplate().get(clazz,id);
}
public void create(T baseBean){
getHibernateTemplate().persist(baseBean);
}
public Query createQuery(String hql){
return getSession().createQuery(hql);
}
public void delete(T baseBean){
getHibernateTemplate().delete(baseBean);
}
@SuppressWarnings("unchecked")
public List<T> list(String hql){
return getHibernateTemplate().find(hql);
}
public int getTotalCount(String hql, Object...params){
Query query = createQuery(hql);
for(int i = 0;params!=null && i<params.length;i++)
query.setParameter(i+1,params[i]);
Object obj = createQuery(hql).uniqueResult();
return((Long)obj).intValue();
}
@SuppressWarnings("unchecked")
public List<T> list(String hql,int firstResult,int maxResults,Object...params){
Query query = createQuery(hql);
for(int i = 0;params!=null && i<params.length;i++)
query.setParameter(i+1,params[i]);
List<T> list = createQuery(hql).setFirstResult(firstResult).setMaxResults(maxResults).list();
return list;
}
public void save(T baseBean){
getHibernateTemplate().save(baseBean);
}
} 展开
import java.util.List;
import org.hibernate.Query;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import dao.IDao;
public class DaoImpl<T> extends HibernateDaoSupport implements IDao<T> {
@SuppressWarnings("unchecked")
public T find(Class<T> clazz, int id){
return(T) getHibernateTemplate().get(clazz,id);
}
public void create(T baseBean){
getHibernateTemplate().persist(baseBean);
}
public Query createQuery(String hql){
return getSession().createQuery(hql);
}
public void delete(T baseBean){
getHibernateTemplate().delete(baseBean);
}
@SuppressWarnings("unchecked")
public List<T> list(String hql){
return getHibernateTemplate().find(hql);
}
public int getTotalCount(String hql, Object...params){
Query query = createQuery(hql);
for(int i = 0;params!=null && i<params.length;i++)
query.setParameter(i+1,params[i]);
Object obj = createQuery(hql).uniqueResult();
return((Long)obj).intValue();
}
@SuppressWarnings("unchecked")
public List<T> list(String hql,int firstResult,int maxResults,Object...params){
Query query = createQuery(hql);
for(int i = 0;params!=null && i<params.length;i++)
query.setParameter(i+1,params[i]);
List<T> list = createQuery(hql).setFirstResult(firstResult).setMaxResults(maxResults).list();
return list;
}
public void save(T baseBean){
getHibernateTemplate().save(baseBean);
}
} 展开
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询