hibernate 从前台获得一个数据模糊查询某表的三个字段,用concat和Restrictions,

DetachedCriteria infoQuery = DetachedCriteria.forClass(Info.class);
// 在business,name,description 中模糊查询含keywords的info
//数据库表字段是business_  ,  name_  ,description_  .entity里是 business, name,description
infoQuery.add(Restrictions.sqlRestriction("CONCAT(business_,name_,description_) LIKE (?), '%"+ keywords + "%', Hibernate.STRING"))

你可能感兴趣的:(java,hinernate,匹配查询)