Java 查询未按预期返回记录

Java 查询未按预期返回记录,java,spring-data-jpa,Java,Spring Data Jpa,下面的查询按预期提供记录 @Query("From Transaction tr where tr.account.bankCustomer.customer.rokaId=?1 and tr.account.accountType=?2 order by createdDate desc") List<Transaction> findTransactioForCorporate(String customerRokaId,AccountType accountType); 下面

下面的查询按预期提供记录

@Query("From Transaction tr where tr.account.bankCustomer.customer.rokaId=?1 and tr.account.accountType=?2 order by createdDate desc")
List<Transaction> findTransactioForCorporate(String customerRokaId,AccountType accountType);
下面的一个按预期给我记录

@Query("From Transaction tr where tr.account.customerInvitation.owner.rokaId=?1 and tr.status !=?2 order by createdDate desc")
List<Transaction> findTransactioForCorporate(String ownerRokaId,Status status);
但是下面的一个只返回满足我第二个查询的记录。tr.account.customerInvitation.owner.rokaId=?3和tr.status!=?四,

@Query("From Transaction tr where (tr.account.bankCustomer.customer.rokaId=?1 and tr.account.accountType=?2) Or (tr.account.customerInvitation.owner.rokaId=?3 and tr.status !=?4) order by createdDate desc")
List<Transaction> findTransactioForCorporate(String customerRokaId,AccountType accountType,String ownerRokaId,Status status);
我做错了什么。
我使用的是spring数据jpa 1.7,1,请帮助我

您在连接的OneToOne映射字段中有空值问题可能第一次查询的用户没有CustomerVitiation,这会将您的结果减少到第二次查询的记录,例如

select a from AppUser a where a.username is not null or a.role.name = :name

如果我有3个用户,只有一个与角色连接,两个尚未连接,则查询将只返回一个用户,但如果我将删除或a.role.name=:此查询将返回3个用户的或语句的名称部分。要了解更多信息,您可以去。

我仍然无法找到解决方案。