Sanjay Jain
Sanjay Jain

Reputation: 3587

Hibernate Session instances

Is it possible to have two (or more) instances of a Hibernate session at the same time?

Upvotes: 0

Views: 290

Answers (2)

lalit
lalit

Reputation: 1475

It's very common in web applications to have multiple sessions working at same time. One thing you want to be careful about your commit strategy. You can either have last commit wins or some sort of versioning strategy in place to take care of data integrity.

Upvotes: 0

Aravind Yarram
Aravind Yarram

Reputation: 80192

Yes you can have multiple sessions open at the same time BUT you SHOULD NOT SHARE THEM across threads as Session's are not thread safe. Here is the JavaDoc for Session.

Upvotes: 4

Related Questions