Re: ORM or JDBC?
On Wed, 23 Mar 2011, Alessio Stalla wrote:
Existing Java ORMs (those known to me, at least) fail at mapping complex
enough object graphs. Relations are not (only) Collections, as ORMs
would like us to believe. Collections cannot be a) filtered and b)
joined without for() loops in Java.
a) parent.getAdultChildren() can only be implemented as
removeMinors(parent.getAllChildren()).
b) grandParent.getGrandChildren() can only be implemented as for(Person
p : parent.getAllChildren()) { collect(p.getAllChildren(); }.
Eh? You would do those as queries in JPA.
That's probably fine (even if too verbose and not easily parallelizable)
for objects in memory, but it's completely stupid for objects fetched
from a database. Dropping to JQL, criteria, or SQL is not a solution,
because it means stepping outside the OO world to return to a relational
view of the world.
Oh, i see. Nah, JPQL is a query language for objects, so it doesn't
involve stepping outside the model. Claiming otherwise is a bit like
claiming that using SQL means stepping outside the relational model
because it involves more than going through a ResultSet.
tom
--
I am predictable. I worry about this, but then I think, "I am predictable
but right, so I don't care." -- coffeeandink