I'm trying to use the array operators such as @>
, <@
or $$
. However I got at the symbolic character @
this my request:
@Transactional
@Modifying
@Query(
"update EbOrder o set o.xEbEtablissement= :newEtablissement " +
"where o.xEbEtablissement = (select distinct u.xEbEtablissement" +
"from EbOrder o, EbUser u" +
"where regexp_split_to_array(:listLabels, ',') @> (regexp_split_to_array(o.listLabels,','))" +
"and u.ebUserNum= :userNum and o.xEbEtablissement = :oldEtablissement)"
)
public int updateOrderEtablissementAndLabels(
@Param("userNum") Integer userNum,
@Param("oldEtablissement") EbEtablissement oldEtablissement,
@Param("newEtablissement") EbEtablissement newEtablissement,
@Param("listLabels") String listLabels
);
The error is:
Caused by: org.hibernate.QueryException: unexpected char: '@' [update com.adias.mytowereasy.delivery.model.EbOrder o set o.xEbEtablissement= :newEtablissement where o.xEbEtablissement = (select distinct u.xEbEtablissementfrom EbOrder o, com.adias.mytowereasy.model.EbUser uwhere regexp_split_to_array(:listLabels, ',') @> (regexp_split_to_array(o.listLabels,','))and u.ebUserNum= :userNum and o.xEbEtablissement = :oldEtablissement)]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.doCompile(QueryTranslatorImpl.java:235) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.hql.internal.ast.QueryTranslatorImpl.compile(QueryTranslatorImpl.java:143) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:119) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.engine.query.spi.HQLQueryPlan.<init>(HQLQueryPlan.java:80) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
at org.hibernate.engine.query.spi.QueryPlanCache.getHQLQueryPlan(QueryPlanCache.java:153) ~[hibernate-core-5.3.7.Final.jar:5.3.7.Final]
Thanks in advance
Those would work only for native queries. HQL has no concept of Postgres' array operators, and doesn't provide similar operators of its own since not all databases would support them. So tack on a native = true
and rewrite the query in pure SQL instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.