[942196 views]

[]

[toggle ads]

Odi's astoundingly incomplete notes

New entries | Code

Criteria API WTF

From the J2EE tutorial:

EntityManager em = ...;
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<Pet> cq = cb.createQuery(Pet.class);
Root<Pet> pet = cq.from(Pet.class);
cq.select(pet);
TypedQuery<Pet> q = em.createQuery(cq);
List<Pet> allPets = q.getResultList();

The equivalent JPQL query is:

FROM Pet

The equivalent SQL query is:

SELECT * FROM Pet

Clearly SQL is too simple and boring. You really need a bullshit API to produce a simple SQL query. Of course this will ease maintenance, improve performance, reduce code, prevent bugs, speed up development by a factor of 10 and reduce your project cost by 99% at least. A classic case of overengineering.

posted on 2013-07-23 15:06 CEST in Code | 1 comments | permalink
Yes, finally I found a site complaining about this stupid shit criteria api.