Rants about Java and other internet technologies by Sam Pullara

JPA 2.0 with Criteria

was published on March 15th, 2008 and is listed in Java, Technology, gauntlet

(see: JSR 317 Persistently Improving)

I love the idea of adding a criteria API to JPA, the only thing I hope that they do differently than Hibernate is to implement that API in addition to string queries.  In Gauntlet we had issues where we wanted to use EJB-QL for selecting the right data and then a criteria-like API for applying security and filtering constraints on the query.  We ended up writing a criteria-like API that augmented the WHERE clause of the query to get the behavior that we needed (like described here).  For example, you could do this:

Query q = em.createQuery("SELECT p FROM Project p");
q.addExpression(Expression.notEqual("id", 2));

Or something like that. This would give you the best of both worlds, where you have the expressiveness of the textual query and the ability to further hone that query programmatically.

"JPA 2.0 with Criteria" was published on March 15th, 2008 and is listed in Java, Technology, gauntlet.

Follow comments via the RSS Feed | Leave a comment | Trackback URL

blog comments powered by Disqus

YUI-Mainstream Theme by Buzzdroid.com

 Premium Wordrpess Theme