我有一个名为Device的域对象,具有此属性
@ManyToMany(cascade = CascadeType.MERGE, fetch = FetchType.EAGER)
private Set<Driver> authorizedDrivers = new HashSet<>();
我想进行此查询,但我收到错误(antlr.NoViableAltException:意外AST节点:()
@Query("select dev from Device dev where dev.authorizedDrivers.contains(?1) ")
Set<Device> findDeviceByDriver(Driver driver);
答案 0 :(得分:1)
JPQL没有&#39;包含&#39;表达。您可以尝试此查询:
@Query("select dev from Device dev join dev.authorizedDrivers d where d = ?1")
Set<Device> findDeviceByDriver(Driver driver);