persistence@glassfish.java.net

Question: Relationship between TopLink and TopLink Essentials aka Glassfish persistence

From: Martin Bayly <mbayly_at_telus.net>
Date: Tue, 21 Nov 2006 16:26:10 -0800

What is the relationship between the Oracle TopLink implementation and
the TopLink essentials that was donated to Glassfish?

Or put another way, are features like the SoftCacheWeakIdentityMap
described in the TopLink Cache Concepts documentation also available
within the Glassfish implementation (presumably with vendor specific
configurations)?

The background to this whole question is the ongoing debate about the
best way to use ORM solutions like JPA/TopLink/Hibernate in a single
tier rich client application - usually single user database.

Some people believe a single application level session/entity
manager/persistence context is the best approach as it simplifies having
long lived domain objects attached to user interface controls.

However, this proved to be inappropriate with Hibernate as the Hibernate
Session would just keep growing unless you specifically evicted objects
that were no longer referenced by the UI which can be hard to track.

So the alternative is to use a session/entity manager per interaction
which means you have to be able to reattach detached objects and you may
end up with multiple references to the same object if you are not
careful (with Hibernate you also have to be careful about lazy loading
outside the session - though apparently not with TopLink).

How does the Glassfish implementation handle objects in the persistence
context? If you open an EntityManager session, will TopLink essentials
hold onto any objects loaded into that persistence context until the
EntityManager is closed, or is it possible to set it up with a weak
reference identity mapping, so that if the application no longer holds a
reference to these objects, they will be candidates for GC?

Cheers
Martin