Skip to main content



      Home
Home » Eclipse Projects » EclipseLink » CriteriaBuilder aborted
CriteriaBuilder aborted [message #646289] Thu, 23 December 2010 03:00 Go to next message
Eclipse UserFriend
Just giving my opinion / FWTW feedback. I've been in the process of moving to using the new CriteriaBuilder API instead of the string queries the last months, and gave up on it yesterday.

Yesterday I had to write a sum query and that was the last drop. Not because I thought I wasn't able to get it working (in the end), but the expected time it would cost me. There was very limited documentation and trying to figure it out using the Javadoc documentation and the one example I found on the internet was a puzzle. I mean; it is a simple sum query. I know how to write it in SQL and in JPQL, but it seemed it would cost me half a century worth of study to write it using the CB. For example: it seems to require something called a TupleQuery. WTF? What kind of implementation details are being thrown around in the API? "S-U-M" not tuple. Yes, I know what is required underneath, but please do not bother me with it. I thought the CB was about making things typesafe, not more complex.

Anyhow, it's back to JPQL for now and I'm going to give LiquidForm another look. How to do a sum there took me a 20 seconds google, and the syntax actually makes sense.

String q = select(sum((o.getCustomer(), o.getTotalprice()))
.from(Order.class).as(o)
.groupBy(o.getCustomer())
.having(gt(o.getTotalprice(), 1000))
.toString();

One question remains: what drug was the standard committee on when they dreamt up this CriteriaBuilder monstrosity?

Tom
Re: CriteriaBuilder aborted [message #646375 is a reply to message #646289] Thu, 23 December 2010 10:07 Go to previous messageGo to next message
Eclipse UserFriend
To each his own. Nothing wrong with CriteriaBuilder for those who know how to use it. I recommend the book "Pro JPA 2". But if you're unwilling to figure out what a TupleQuery is, I think you have made the correct decision to stay with what you already know.
Re: CriteriaBuilder aborted [message #647156 is a reply to message #646289] Tue, 04 January 2011 14:25 Go to previous message
Eclipse UserFriend
EclipseLink also allows for queries to be defined using EclipseLink Expression objects and ReportQuerys, you may find these easier to use or better documented.

JPA Criteria is new, so it may take a while for examples and documentation to proliferate for them.
Previous Topic:How can I query all past versions of an object with eclipselink?..
Next Topic:quoted identifiers
Goto Forum:
  


Current Time: Fri Jul 04 10:30:08 EDT 2025

Powered by FUDForum. Page generated in 0.53927 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top