Hello there,
I configured Spring to use transactions around application classes only (eg. class AppEditArtifact, method saveArtifact(Artifact a)), because these classes contain use case implementations. I'm using WebWork, and WebWork actions are not included in the transaction.
In that context, an object retrieved from a Hibernate session in the WebWork action is not the same as one retrieved in the application class even if they have the same Hibernate Id. Searching the forums I found out that this is because Spring uses transaction-scoped Hibernate Sessions. Therefore, the sessions are different and I can't benefit from Hibernate's cache.
Just so you know, I want to use cache primarily because I wouldn't have to override equals() on my domain objects and they work, because both objects would be the same in memory.
What is the best way (or any way) to go around this?
- - Can I configure the action method to PROPAGATION_REQUIRED? If I do so, will it be included in the transaction and therefore use the same hibernate session?
- Can I create some other form of cache? Any suggestions on which form?
- Should I forget about using cache and override equals, preferrably using some tool like Jakarta's commons-lang?
Any answers, pointers and RTFMs are welcome.
Thanks in advance,
- Vítor Souza


Reply With Quote