Hibernate常见问题集锦(2)
1。问题:
?
异常原因:
2010/10/17-22:09:40? WARN Configurator:
126 - No configuration found. Configuring ehcache from ehcache-failsafe.xml found in the classpath: jar:file:/D:/%e6%88%91%e7%9a%84%e6%96%87%e6%a1a3/workspace/ePetSSH/WebRoot/WEB-INF/lib/ehcache-1.1.jar!/ehcache-failsafe.xml
解决办法:
public List<Petinfo> search(Petinfo petinfo, String orderBy) {
??List<Petinfo> lists = null;
??String hql = "select p from Petinfo as p where 1=1";
??// 查询对象
??Query query = null;
??// 宠物名
??if (petinfo.getPetName() != null && petinfo.getPetName().trim() != "") {
???hql += " and p.petName like :petname";
???System.out.println(hql);
???query = getSession().createQuery(hql);
???query.setString("petname", "%"+petinfo.getPetName()+"%");
??}
??// 宠主
??if (petinfo.getPetOwnerName() != null
????&& petinfo.getPetOwnerName().trim() != "") {
???hql += " and p.petOwnerName=:petownername";
???System.out.println(hql);
???query = getSession().createQuery(hql);
???query.setString("petname", "%"+petinfo.getPetName()+"%");
???query.setString("petownername", petinfo.getPetOwnerName());
??}
??????? //執行查詢
??System.err.println("Search方法的查询语句:::"+hql);
??lists = query.list();
??return lists;
?}
看到红色加粗的字体了吧!需要对重新组建的hql语句重新赋值!
?
?
?
2.问题描述:
?
2010/10/18-00:31:04 ERROR PARSER:33 - line 1:54: expecting IDENT, found '*'
?
问题分析:
?
?