Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » EciplseLink Caching - Strange behaviour (While using Eclipse Link with Spring JPA and default setting, I am getting complete non-sense behavior with the cache.)
EciplseLink Caching - Strange behaviour [message #1745047] Tue, 04 October 2016 13:25 Go to next message
Taylor Davenport is currently offline Taylor DavenportFriend
Messages: 2
Registered: October 2016
Junior Member
Spring 4.0.8
Spring Data - JPA 1.9.4
Spring Data - Commons 1.11.4
Eclipse Link Persistence 2.5.0
MSSQL - 2016

I have a project where I have defined JPA Entities with a NamedStoredProcedureQuery that takes in parameters and returns a User entity. I only use store procedures to access the data and not JPA repositories. I have left the caching and all other settings as default other than disabling EclipseLink weaving.

When I execute the StoredProcedure, I get a partial entity returned. After debugging the code, I can see the request go to the database, get the full and complete user record, then do nothing with it.

org.eclipse.persistence.internal.descriptors.ObjectBuilder.buildWorkingCopyCloneNormally()

My question is in what circumstance would it ever make more sense to return a partial set of data from a cache instead of using the data returned from the database? My impression is that the cache is supposed to save a trip to the database. On virtue of this alone I plan on ditching eclipse link completely, but as a last effort to at least understand I am posting here.


Re: EciplseLink Caching - Strange behaviour [message #1745061 is a reply to message #1745047] Tue, 04 October 2016 17:01 Go to previous messageGo to next message
Chris Delahunt is currently offline Chris DelahuntFriend
Messages: 1275
Registered: July 2009
Senior Member
If you are getting a partial object back, it is because either one of your queries is only returning partial data, forcing that incomplete entity to get cached and return on subsequent requests, or that is what you are somehow persisting/merging. The cache does not save a round trip to the database - especially not if you are using stored procedures, since they only run in the database. What it can do with though is reduce the expense in rebuilding the entities, and the cache has an associated identity map allows object identity to be preserved within the context.

You need to determine how this partial object first got loaded, and determine how best to handle it from there. Queries allow hints that can prevent an entity from being cached, or that can force the entity being rebuilt from the returned data. See https://wiki.eclipse.org/EclipseLink/Examples/JPA/Caching and https://wiki.eclipse.org/EclipseLink/UserGuide/JPA/Basic_JPA_Development/Querying/Query_Hints

Regards,
Chris
Re: EciplseLink Caching - Strange behaviour [message #1745063 is a reply to message #1745061] Tue, 04 October 2016 17:34 Go to previous message
Taylor Davenport is currently offline Taylor DavenportFriend
Messages: 2
Registered: October 2016
Junior Member
I did manage to find where the partial data is coming from. What I don't yet understand is why it's 'preferring' cached data to the data it just retrieved from the database? Shouldn't it attempt to merge the records at a minimum and fill in the blanks with the cache?

Given that using stored procedures only is probably considered a non-standard implementation, would be disabling the cache completely or using only isolated cache be an acceptable work around? I don't see any value added unless JPA or native queries are used in addition to the stored procedures.
Previous Topic:Eclipselink - error mapping oracle object when calling stored procedure
Next Topic:Criteria Distinct on (column)
Goto Forum:
  


Current Time: Tue Dec 12 15:58:25 GMT 2017

Powered by FUDForum. Page generated in 0.01558 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software