from com.huayiluo.hibernate.pojo.Product where match (uuid,title,intro,color,size,description) against('a' in boolean mode) and status=1 order by hotSale desc这是hibernate的语句问题出现在match against(hibernate 好像不支持。)https://forum.hibernate.org/viewtopic.php?p=2256280
国外的人有一个解决方案。可是不太懂。
请问有什么办法解决。我搜索百度,好像没有人出现过这种问题
国外的人有一个解决方案。可是不太懂。
请问有什么办法解决。我搜索百度,好像没有人出现过这种问题
return (List)getHibernateTemplate().execute(new HibernateCallback(){
public Object doInHibernate(Session session) throws HibernateException, SQLException {
Query query=session.createSQLQuery(sql).addEntity(cls);
if(min!=0)
query.setFirstResult(min);
if(max!=0)
query.setMaxResults(max);
return query.list();
}});
}我想他返回List<Product>
import org.hibernate.dialect.MySQL5Dialect;
import org.hibernate.dialect.function.SQLFunctionTemplate ; public class MySQL5LocalDialect extends MySQL5Dialect {
public MySQL5LocalDialect(){
super();
registerFunction("convert", new SQLFunctionTemplate(Hibernate.STRING, "convert(?1 using ?2)") );
}
}现在applicationContext.xml中或hibernate.hbm.xml中修改 package.MySQL5LocalDialect <property name="hibernate.dialect">
com.credit.publicmodel.util.MySQL5LocalDialect
</property> 现在HQL中使用convert方法, 例如: convert(fieldName, 'gbk') , "GBK"也可以是其他字符集---------------------------------------
别人的文章应该可以处理掉我的问题,可是我不知道怎么修改。