Harald.Pichler wrote:
For performance reasons I want to keep some often-used objects in memory. These objects are read-only and are referenced by other objects. For this reason I implemented a small cache.
However, I run into problems when referencing these objects, because I have another session then. If I have both sessions open, I get a "Illegal attempt to associate a collection with two open sessions" Exception. The same happens if I evict the object from the retrieval session. If I close the retrieval session, the programs runs through, but the object is updated, which I wanted to prevent.
Is there a possibility to reference read-only objects in a different session?
Hibernate version: 2.1.3
You can evict() the objects from the first session as you read them in, then the 2nd session won't have an issue.