0
我是JPA的新手。使用JPA Criteria API選擇查詢當實體類有一個子類時(嵌入ID)
我已經找到了如何使用JPA標準API在下面的鏈接: JPA Criteria API with multiple parameters
謂詞的代碼是:
Root<CustomerEntity > customerEntity = cq.from(CustomerEntity.class);
List<Predicate> predicates = new ArrayList<Predicate>();
//Adding predicates in case of parameter not being null
if (param1 != null) {
predicates.add(
qb.equal(customerEntity.get("fieldName"), param1));
}
但我的客戶實體類有一個嵌入的ID(複合主鍵)
如何使用JPA標準API在這種情況下
是否所有的嵌入式ID對象值也是強制搜索(選擇查詢)?
嗨,我不能從數據庫中得到任何結果集,如果我沒有設置嵌入式ID對象的所有值。我需要這些字段對於選擇查詢(搜索)是可選的。這可能嗎? – firstpostcommenter