Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

coalesce

673147Oct 12 2010 — edited Oct 14 2010
Hi i normally do this with a SQL query:

SELECT * FROM persons WHERE person_id = coalesce(:mi_variable, person_id);

If i run this query and "pass" value to my bind variable (mi_variable) i get the person who i need with the same id (excepted behaivor), but when i want to recover all the person i send NULL to bind variable (mi_variable) and with coalesce function, all the person_id matchs and i get all of them (excepted behaivor)

But i dont know how to translate this to JPA ( <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>).


CriteriaBuilder cb = entrerpriseManager.getCriteriaBuilder();
CriteriaQuery cq = cb.createQuery();
Root<Persons> per = cq.from(Persons.class);

cq.where( cb.coalesce() )......... <----- at this point i dont know how to do it.

Thanks 4 help!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 11 2010
Added on Oct 12 2010
1 comment
248 views