Fixed
Details
Assignee
Steve EbersoleSteve EbersoleReporter
Steve EbersoleSteve EbersoleTime tracking
6.12h loggedFix versions
Priority
Major
Details
Details
Assignee
Steve Ebersole
Steve EbersoleReporter
Steve Ebersole
Steve EbersoleTime tracking
6.12h logged
Fix versions
Priority
Created December 17, 2012 at 7:34 PM
Updated April 22, 2015 at 6:40 PM
Resolved January 31, 2013 at 10:47 PM
Currently, all data stored into the second level cache is handled the same way. The data is first disasembled into a state array, that array is deep copiedand that deep copy is put into the cache. The reverse is done for reading from the cache. For example, take an entity named
ZipCode
:@Entity @Immutable public class ZipCode { @Id public Integer id; public Integer code; public Integer plus4; }
Currently, storing that into the second level cache would:
disasseble the ZipCode into its basic state as an array (
[code,plus4]
)deepCopy that array
#push that array copy on to the cache
All cacheable data that is mutable needs to continue to be handled this way.
However, for immutable (aka "reference") data there are more efficient ways to store the information. Within immutable data there is still a further distinction we need to make with regards to associations. Does the reference data define associations (many-to-one, etc)?
In the simpliest case, consider reference data with no associations like we have above with
ZipCode
. Here it is feasible to store theZipCode
reference directly into the cache. With a caveat... the developer needs to understand that in memory changes to thisZipCode
would now directly "write through" to the cache. Dangerous.At the other extreme for cacheable reference data would be reference data with one or more associtions to mutable (transactional) data. Here we absolutely would not be able to directly write the object instance out to the second level cache region. We clearly need the disassembly. However, the deepCopy is actually unnecessary in this case.
In between we have a gray area with regard to cacheable reference data with associations to nothing but other immutable reference data, such as the case of
ZipCode
with reference to theState
it belongs to:@Entity @Immutable public class State { @Id private Integer id; ... } @Entity @Immutable public class ZipCode { @Id public Integer id; public Integer code; public Integer plus4; @ManyToOne public State state; }
Here it would be possible to cache
ZipCode
"whole". Not sure yet though if that is what we want.