我尝试创建本机 sql 查询并使用参数映射到实体类但失败。
/**
* @return
*/
public List<PoolRuleMapping> getAllPRM() {
Session session = null;
List<PoolRuleMapping> prmList = null;
try {
session = HibernateSessionFactory.getSession();
Query q = session.createSQLQuery("select * from pool_rule_mapping").addEntity(PoolRuleMapping.class);
prmList = q.list();
} catch (HibernateException e) {
} finally {
session.close();
}
return prmList;
}
请举个例子。谢谢。