使用union的多个实体的JPA查询

时间:2016-08-09 09:43:49

标签: mysql spring entity spring-data-jpa jpql

我在JpaRepository中写了一个查询,以获取当前用户创建的所有账单的列表,以及当前用户的下属。我尝试使用下面的代码。它没有显示任何错误但返回空。我使用了mysql

public interface BillRepository extends JpaRepository<Bill, Long>{
@Query("select b from Bill b where b.createdBy = ?1 union select bb from Bill bb where bb.createdBy in (select r from Resource r where r.reportingManager = ?1)")
    Page<Bill> findAllByPage(Long id,Pageable page);
}

请提供解决方案。谢谢提前

0 个答案:

没有答案
相关问题