简体   繁体   中英

Jpa query and, or using

I wrote a query but this query returns this error.Do you have any idea?I guess that I get this error because of parenthesis

 @Query("select u from Context u where u.user.id <> :userId and u.publicWatch = 1 and  u.isDeleted = 0 and (u.contextType.id  IN :contextTypeId  or u.status IN :status)")
Page<Context> findFilteredContexts(@Param("userId") Long userId,@Param("contextTypeId") List<Long> contextTypeId,@Param("status") List<String> status, Pageable pageable);

The error:

Caused by: java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected AST node: {vector} [select count(u) from com.huawei.ti.ei.web.domain.Context u where u.user.id <> :userId and u.publicWatch = 1 and u.isDeleted = 0 and (u.contextType.id IN (:contextTypeId_0_) or u.status IN :status_0_, :status_1_)]

If you are using an older version of hibernate you have to surround your IN parameters with parenthesis (:status) ( HHH-5126 )

Affected version 3.5.1 -3.6 but looking at the comment someone report newer version too...

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM