hibernate - SQL Replace in HQL -


any idea why snippet of hql failing.. replace function requires 3 arguments error. there other way perform replace in hql>?

"where :url ('%' || replace(atf.title,'*','') || '%')" +

hql not support replace function.

so have make own custom dialect , register replace function throught dialect::registerfunction method

for example registering replcae in postgres dialect 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 custom dialect in persistence.xml or hibernate.cfg.xml file


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -