hibernate list 查出来的List数组怎样获取它里面的值

2025-01-18 18:12:50
推荐回答(1个)
回答1:

public class Base{
private SessionFactory sessionFactory;

public SessionFactory getSessionFactory()
{
return sessionFactory;
}
public void setSessionFactory(SessionFactory sessionFactory)
{
this.sessionFactory = sessionFactory;
}
public final Session getSession()
{
return this.sessionFactory.getCurrentSession();
}
@SuppressWarnings("unchecked")
public List executeQuery(String hql)
{
return (List) this.getSession().createQuery(hql).list();//执行传入的sql,并返回一个list
}
}