我有一个“SpringDataJPA”查询,我觉得很难看,因为我需要多次传入同一个用户ID。
Page<CompanyEntity> findByClients_User_IdOrOwners_User_IdOrRelations_User_IdOrProjectManagers_User_IdOrSpecialists_User_Id(Long userId1, Long userId2, Long userId3, Long userId4, Long userId5, Pageable page);
正如建议的那样,我应该重写此查询以使用JPQL。
但是我被困在如何从集合中获取用户对象的问题上
编辑:
@Query("SELECT company FROM CompanyEntity company JOIN company.owners owners JOIN company.clients clients JOIN company.projectManagers managers JOIN company.specialists specialists JOIN company.relations relations")