解决思路一(采用hql查询):
String sql = "select a from DocCatalogInfo a where a.catCode like '"+catCode+"%'";
List catNameList =getHibernateTemplate().find(sql);
return catNameList ;
ok,测试一下发现没问题,看来还是因为用原生sql查询的原因,网上搜一下:createsqlQuery返回对象,看到一篇文章才觉悟到:
解决思路二(采用原生sql查询):
String sql = "select a.* from tb_doc_catalog a where a.cat_code like '"+catCode+"%'";
Session session = this.getSession();
try {
List catNameList = session.createSQLQuery(sql).addEntity(DocCatalogInfo.class).list();
return catNameList ;
} finally {
releaseSession(session); //释放session
}
又ok了。
该篇文章也贴上来:
联系客服