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
Post a Comment