persistence@glassfish.java.net

Re: Do objects in the cache time out?

From: Markus Fuchs <Markus.Fuchs_at_Sun.COM>
Date: Tue, 27 Feb 2007 13:38:59 -0800

Hi Jon,

Jon Miller wrote:
> Hi all,
>
> One area of Glassfish Persistence that I'm still a bit shaky on is how
> the caching works. I'm wondering if there is documentation somewhere
> that explains it?
>
Check out:

http://weblogs.java.net/blog/guruwons/archive/2006/09/understanding_t.html
> One of the things I'm wondering is if objects in the cache time out?
> If so, how long is it before they timeout?
>
> The other thing that I'm wondering is if collections in an entity are
> changed at all when you close the EntityManager that is managing the
> entity? One of the issues that I've ran into is problems maintaining
> bidirectional relationships. What I was doing is managing the
> relationships while the entities were in the detached state. I'm
> wondering if this is not a valid thing to do? Oddly, when I tried to
> create a unit test to test it, it seemed to work OK, so, maybe I'm
> doing something else wrong in the code that I was having problems
> with. The problem that I ran into only happened when I was using the
> default setting which is to use the global cache.
>
Be aware that TopLink-Essential caches relationship fields between
transactions (in Java SE or extended persistence contexts). It is
important to maintain bi-directional relationships on both sides.
Maintaining relationships while entities are detached should work ok,
as long the relationships specify cascade=MERGE..

HTH,

-- markus.
> Jon