Dynamic JPA 2.0 query using Criteria API

Posted by rrrrrrrrrrrrr on Stack Overflow See other posts from Stack Overflow or by rrrrrrrrrrrrr
Published on 2010-03-24T17:45:18Z Indexed on 2010/03/25 12:13 UTC
Read the original article Hit count: 500

Filed under:
|
|

Hello all,

I am a bit stucked constructing a dynamic query using the CriteriaBuilder of JPA 2.0.

I have quite a common use case I guess: User supplies a arbitrary amount of search parameters X to be and / or concatenated: like :

select e from Foo where (name = X1 or name = X2 .. or name = Xn )

The Method or of CriteriaBuilder is not dynamic:

Predicate or(Predicate... restrictions)

Ideas? Samples?

© Stack Overflow or respective owner

Related posts about jpa

Related posts about criteria-api