Hi,
I'm facing the problem of having some non persistent attributes which are caculated at runtime. These attributes obviously do not get cached in second level cache (which is essentially just the JDBC data).
This behaviour forces me to recalculate the values over and over again, which is everything but satisfying (especially since some of the calculations are REALLY expensive).
I also tried a little workaround using a custom UserType. Although I ended up with my attribute being cached there is some SERIOUS problem I'm having with this approach:
1. I really don't think that any of my non persistent attributes should be specified in the mapping file!
2. Beeing an attribute of the mapping file it needs to be mappend to a column . Also you could use any column in insert=false, update=false mode or formula this is more than a 'little hack' to me... it's just dirty style!
3. The idea of having a seperate class / user type for every transient attribute just to be able to cache... I don't think I have to say anything more on this. Also all these methods like nullSafeGet(..), sqlTypes(), ... stuff I just don't need here
As far as I know HbmBinder is used to parse the mapping file and analyize which attributes are beeing cached, what is the pk and so on. Is there any way to enhance this (or any other) class to also consider the transient properties of my domain objects (or cache the whole object like TopLink does)?
This problem seems to be sooo straight forward to me that I'm almost sure that I'm missing something here. It can't be that tricky, can it?! #
And if there is really no other way I'm sure some of you guys (if not all) are in the same situation of not wanting to throw away already initialized data...PLEASE letme know what the heck you are doing to get around this issue in a nice and clean way.
This has really been giving me the biggest headaches for the last weeks!
Looking forward to your answers... :-)