Any idea why this snippet of HQL would be failing.. REPLACE function requires three arguments is the error. Is t开发者_StackOverflow社区here any other way to perform a replace in HQL>?
"WHERE :url LIKE ('%' || REPLACE(atf.title,'*','') || '%')" +
HQL does not support REPLACE function.
So you have to make your own custom dialect and register REPLACE function into it throught Dialect::registerFunction method
For example i am registering REPLCAE in postgres dialect like in next code
import org.hibernate.dialect.PostgreSQL9Dialect;
import org.hibernate.dialect.function.StandardSQLFunction;
public class MyPostgreSQL9Dialect extends PostgreSQL9Dialect {
public MyPostgreSQL9Dialect() {
super();
registerFunction("replace", new StandardSQLFunction("replace"));
}
}
then refer to this custom dialect in your persistence.xml or hibernate.cfg.xml file
精彩评论