Poni
Poni

Reputation: 11337

hibernate multi-thread-multi-session and objects

Few facts regarding the setup:

Having the above setup I'm getting errors such as:

My understanding is that

The question is obvious:

I could of course avoid all of it if I'd use only one Session object but that sounds so... blocking (thread-wise).

I'm sure these sort of issues were solved long time ago, just need to find it (without re-inventing the wheel).

Upvotes: 1

Views: 4784

Answers (2)

Poni
Poni

Reputation: 11337

Calling clear() before fetching the object(s).

Upvotes: 0

Scorpio
Scorpio

Reputation: 2327

The object is attached to a Hibernate session, yes. It can only be attached to one at a time, yes. Unless you close a Hibernate session, you could try to evict() the object, thus detaching it from the session, making it possible to load it in another thread. Problem is, that this may be unpractical, depending on your program flow.

Upvotes: 1

Related Questions