persistence@glassfish.java.net

Re: Do objects in the cache time out?

From: Jon Miller <jemiller_at_uchicago.edu>
Date: Tue, 27 Feb 2007 15:45:32 -0600

Markus,

Thanks. I think you may have hit the nail on the head as to the problem that
I was running into. I think I didn't have a Cascade.MERGE. So the
relationship was only getting updated on one side in the cache even though I
was maintaining both sides while in the detached state. I'll have to keep an
eye out for that in the future.

Jon

----- Original Message -----
From: "Markus Fuchs" <Markus.Fuchs_at_Sun.COM>
To: <persistence_at_glassfish.dev.java.net>
Sent: Tuesday, February 27, 2007 3:38 PM
Subject: Re: Do objects in the cache time out?


> 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
>