Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Switched to 2.4.1 - Suddenly caching of lazy relations is missing(Do we miss any new default setting?)
Switched to 2.4.1 - Suddenly caching of lazy relations is missing [message #1010960] Mon, 18 February 2013 10:01 Go to next message
R. Oldenburg is currently offline R. Oldenburg
Messages: 24
Registered: September 2011
Junior Member
Hey guys,

we are using EL 2.2 and 2.3.x successfully for the last 2 years now.
Now recently when I tried switching to EL 2.4.1 we encounter some strange behaviour:

We got a complex object/entity hierarchy with several lazy bi-directional mappings that now seem to be newly fetched on every access... (i.e. calling getRelatedObjects().iterator())

Did something important change on the lazy relation handling?
Could it be related to @JoinFetch(JoinFetchType.OUTER) or to our default WEAK shared cache setting?

In EL 2.3 the already fetched relational entities have been perfectly efficient re-used. (SQL-"Fine"-Log was some 2,5MB and now some 58 MB for the same routine. It contains the same SQLs over and over again)

I am totaly out of ideas currently...

Thanks in advance,
R. Oldenburg
Re: Switched to 2.4.1 - Suddenly caching of lazy relations is missing [message #1013393 is a reply to message #1010960] Sat, 23 February 2013 10:03 Go to previous messageGo to next message
R. Oldenburg is currently offline R. Oldenburg
Messages: 24
Registered: September 2011
Junior Member
Really...? Nobody got an idea...?
Re: Switched to 2.4.1 - Suddenly caching of lazy relations is missing [message #1014835 is a reply to message #1013393] Tue, 26 February 2013 10:05 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

With a WEAK cache setting, the shared object can garbage collect, so the objects may not be in the cache. Try setting the cache to HARD_WEAK.

Also ensure you are not starting an early transaction before accessing the objects, then they may never get into the shared cache.


James : Wiki : Book : Blog : Twitter
Re: Switched to 2.4.1 - Suddenly caching of lazy relations is missing [message #1015913 is a reply to message #1014835] Mon, 04 March 2013 04:17 Go to previous messageGo to next message
R. Oldenburg is currently offline R. Oldenburg
Messages: 24
Registered: September 2011
Junior Member
Thanks for these hints.
Yes, of course, we use WEAK to have that behaviour. This was the intention. But if I understand correctly WEAK does only release these cached objects if JVM decides that memory is too low and needs to be freed up.
This should not be the case here.

And even if so: Where is the main cause for this difference to the previous 2.3.1 version?

Early transaction would mean
"getTransaction.begin() -> load and persist entities -> commit()"
, correct?

Then no, no early transaction.

We do
entMgr.getTransaction().begin(); entMgr.flush(); entMgr.getTransaction().commit();

Thanks again.
Re: Switched to 2.4.1 - Suddenly caching of lazy relations is missing [message #1016231 is a reply to message #1015913] Tue, 05 March 2013 10:03 Go to previous messageGo to next message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

No, WEAK will release the objects on every garbage collection. SOFT will only release when the JVM decides memory is low (however some JVM's always think memory is low).



James : Wiki : Book : Blog : Twitter
Re: Switched to 2.4.1 - Suddenly caching of lazy relations is missing [message #1016469 is a reply to message #1010960] Wed, 06 March 2013 10:08 Go to previous messageGo to next message
R. Oldenburg is currently offline R. Oldenburg
Messages: 24
Registered: September 2011
Junior Member
OK. Thanks for clarification.

But still. Even when playing around with cache and reference settings, and even if I don't set any option on caching (so leave all on default):

nothing different happens...
All relations are lazily loaded and then re-loaded again and again on every access.

And still:
Completely different on EL 2.3.x!
The routine is 10 times faster (easy due to the cached, not-re-loaded relations being reused)

What am I missing? Where is the diff when using EL 2.4?
Re: Switched to 2.4.1 - Suddenly caching of lazy relations is missing [message #1016829 is a reply to message #1016469] Thu, 07 March 2013 15:23 Go to previous message
James Sutherland is currently offline James Sutherland
Messages: 1939
Registered: July 2009
Location: Ottawa, Canada
Senior Member

It could be something else, although nothing I know of changed in 2.4 to cause anything like this.
Are you using Spring?
Does it happen with all of your classes, or just some of them. Perhaps try to isolate/debug the issue.
If you have a simple test, you could attach the code and the log on finest.


James : Wiki : Book : Blog : Twitter
Previous Topic:naming conflict on generating classes from xsd
Next Topic:Entity instance not rollbacked
Goto Forum:
  


Current Time: Fri Apr 18 01:40:49 EDT 2014

Powered by FUDForum. Page generated in 0.35354 seconds