Querydsl不支持not()吗?

问题描述 投票:0回答:1
//update q_top_banner set banned = !banned where id = x;
queryFactory.update(Q_TOP_BANNER)
  .set(Q_TOP_BANNER.banned, Q_TOP_BANNER.banned.not())
  .where(Q_TOP_BANNER.eq(id))
  .execute();

MySQL55Dialect com.mysql.cj.jdbc.Driver。

java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: not near line 2, column 24 [更新 com.gzlh.xiaolian.news.entity.TopBanner topBannerset topBanner.banned = not topBanner.banned]。

querydsl
1个回答
0
投票

QueryDSL支持它,但Hibernate在DML查询中不支持它。

取而代之的是 NOT,你必须使用 ! 运营商那里。例如:

queryFactory.update(Q_TOP_BANNER)
  .set(Q_TOP_BANNER.banned, Expressions.booleanTemplate("!{0}', Q_TOP_BANNER.banned))
  .where(Q_TOP_BANNER.eq(id))
  .execute();
© www.soinside.com 2019 - 2024. All rights reserved.