public List getList(int xh)
{
String where="";
if(xh!=0)
{
where=where+" where xuehao="+xh+"";
}
return this.findAll(where);
}
下边是findAll方法
private List<Xuesheng> findAll(String where)
{
Session sess = this.getSessionFactory().openSession();
try
{
Query query = sess.createQuery(" From Xuesheng " + where + " order by id ");
return query.list();
}
finally
{
sess.close();
}
}