NullPointerException on QueryDSL where clause
问题 Using Query DSL with hibernate (Spring Data JPA) to build a query like so if( bankId != null ){ query.where( coopMember.personId.bankAccountId.isNotNull().and( coopMember.personId.bankAccountId.bankBranch.bankId.eq(bankId)) ); } return query.fetch(); The logic here is simple: if there is a bank account associated with a person, filter the results by bank id. The BankAccount entity has a BankBranch which holds bankId integer value. A CoopMember entity may or may not have a BankAccount Problem