Session « Relationship « JPA Q&A

1. Hibernate Session Connection Relationship

How many connection will hold for a single hibernate session where there is only one DB?

2. Removing bi-directional relationships with session.update

I am working in an environment where we will need to load an object from Hibernate and pass it to a Web layer where a user can update the object. We will update the object and reassociate the object back to a new session and save the object. This works as the documentation describes. However, we also have situations where we ...

3. Session management of Foreign key relationship

It looks like your code is leaking Sessions, it certainly doesn't look correct. You should reconnect(), not open a new Session, if you disconnect(). Don't forget to close() it at some point. This is more advanced than you might realize, don't use disconnect()/reconnect() unless you are implementing long running Application Transactions with a single Session. See Hibernate in Action for more ...