Hi Pinaki,
i am able to gerenate dynamic query, the way you suggested. I have written
query in below format
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Object[]> cq =
cb.createQuery(Object[].class);
Root<Certificate> cert = cq.from(Certificate.class);
Join<Certificate, Loan> l = cert.join("loan");
SetJoin<Loan, Borrower> lb = l.joinSet("loanBorrowers");
Join<Loan, Branch> b = l.join("branch1");
Join<Branch, Customer> cu =
b.join("FK__Branch__Customer");
cq.where(cb.equal(lb.get("ssnNumber"), "ValueFromRequest"),
cb.equal(lb.get("loan_Brwr_Seq_ID"), 1),
cb.equal(cu.get("Cust_Number"),
"value_from_request"),
cb.equal(b.get("Branch_Check_Digit"),
"value_from_request"));
cq.multiselect(cert.get("Cert_Number"),
lb.get("ssnNumber")).distinct(true);
TypedQuery<Object[]> typedQuery = em.createQuery(cq);
List<Object[]> result = typedQuery.getResultList();
Now my question is: cq.where condition has all parameters values, there are
chances that user may not enter ssnNumber for search criteria. how do i put
a check so that in result query, i can not have where condition for
ssnNumber or any other parameter?
Thanks
Chintan
--
View this message in context:
http://openjpa.208410.n2.nabble.com/Example-of-join-in-Criteria-API-tp6291890p6311478.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.