Bellow查询按预期显示记录
@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);
Bellow one按照预期给我记录。
@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 and tr.status!=?4))
@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);
我在这里做错了什么。 我使用的是弹簧数据jpa 1.7,1,请帮助我
答案 0 :(得分:0)
连接(OneToOne映射)字段中的空值存在问题,可能第一个查询中的用户没有customerInvitiation,这会将结果从第二个查询中减少到记录,例如
select a from AppUser a where a.username is not null or a.role.name = :name
如果我有3个用户并且只有一个用角色连接而且两个尚未连接,则查询将只返回一个用户但是如果我将删除or a.role.name = :name
部分or
语句此查询将返回3个用户。有关详细信息,请访问here。