persistence@glassfish.java.net

Dynamic JPA 2.0 query using Criteria API

From: saturon <gsaturon_at_gmail.com>
Date: Wed, 24 Mar 2010 21:03:35 +0100

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?


Rgds Ben