While you are it, you should also seriously consider usng canonical metamodel
classes as opposed to the string based get() method I used in this example.
Otherwise the core advantage of type-safety is only partially realized
(which effectively takes us back to the basic risk of writing queries that
pass the compiler but fail at runtime).
So instead of
c.multiselect(b.get("title"), replacedStr);
you should write
c.multiselect(b.get(Book_.title), replacedStr);
where Book_ (with the underscore) is the mea-class that the compiler will
generate while compiling Book.java if you instruct it to do so. Only by
using these canonical meta-classes, you can ascertain type-safety.
For example, if someone had renamed the Book.title field to Book.xyz, the
Criteria query withh simple get() will still break (as a JPQL), but the
strict typed version will fail at compile time itself saving everybody some
trouble.
-----
Pinaki
--
View this message in context:
http://openjpa.208410.n2.nabble.com/Is-this-possible-with-CriteriaBuilder-method-tp6283183p6297829.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.