hibernate like 查询
主要是中文的问题,写在dao里
Code
public List liketxt(String txt) {
log.debug("finding all Log instances");
try {
String queryString = "from Log as a where a.ltxt like ? ";
Query queryObject = getSession().createQuery(queryString);
queryObject.setString(0, "%" + txt + "%");
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
public List liketxt(String txt) {
log.debug("finding all Log instances");
try {
String queryString = "from Log as a where a.ltxt like ? ";
Query queryObject = getSession().createQuery(queryString);
queryObject.setString(0, "%" + txt + "%");
return queryObject.list();
} catch (RuntimeException re) {
log.error("find all failed", re);
throw re;
}
顺便记一下java中的小区别 字符串判等要用equal
作者:魔尊年少时
出处:http://pc-funning.cnblogs.com
出处:http://pc-funning.cnblogs.com
希望您能从这里有所收获,本blog未经特殊说明随笔均为原创。随笔版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。