基于以下文章 JPQL,或者只返回一个条件的结果? 我创建了以下查询
Collection<Profile> profiles = dataManager.load(Profile.class).view("profile-view")
.query("select p from userlifecyclemgmt_Profile p " +
" left join p.legalEntities f where" +
" p.isAvailableForAll = true or :legalEntity MEMBER OF f" )
.parameter("legalEntity", serviceRequest.getHrUser().getLegalEntity())
.list();
参数:legalEntity
是类的对象LegalEntity
。此查询给了我以下错误:
JpqlSyntaxException: Errors found for input jpql:[select p from userlifecyclemgmt_Profile p left join p.legalEntities f where p.isAvailableForAll = true or :legalEntity MEMBER OF f]
CommonErrorNode [<unexpected: [@35,120:125='MEMBER',<113>,1:120], resync=:legalEntity MEMBER OF f>]
使用相同的查询稍作修改:
Collection<Profile> profiles = dataManager.load(Profile.class).view("profile-view")
.query("select p from userlifecyclemgmt_Profile p " +
" left join p.legalEntities f where" +
" p.isAvailableForAll = true or :legalEntity MEMBER OF p.legalEntities" )
.parameter("legalEntity", serviceRequest.getHrUser().getLegalEntity())
.list();
没有错误,但只给了我OR
语句第二部分的结果。我确实了解 JPQL 在后台创建INNER JOIN
查询,这就是原因。但是,如何使第一个查询起作用?
提前致谢!