users@glassfish.java.net

Re: Toplink's em.getReference - terrible :/

From: <glassfish_at_javadesktop.org>
Date: Mon, 25 Jun 2007 22:39:52 PDT

No problem.

In truth, I find the Javadoc on getReference pretty unclear, so I never quite understood what the value of getReference was vs simply find. In the TopLink SourceCode, they are implemented effectively identically. But, now, obviously, it's much clearer.

In fact, we have basically worked around that problem in our application. For our "lookup tables" (for lack of a better term), we walk the object tree to fix these. We simply create "empty" entity objects with just the primary key populated, and then look them up when we merge the object. For us, these are all in the 2nd level cache, so it works out. But we also work with detached objects most of the time in our web tier, so I don't even if getReference did "work", I don't know that it would be applicable to us.

We worked around a lot of JPA issues like this, we also have routines to handle relationship management for us, collection synchronization, etc. We basically have our own merge on top of JPAs merge. Reinvented a bunch of those wheels.
[Message sent by forum member 'whartung' (whartung)]

http://forums.java.net/jive/thread.jspa?messageID=223892