design « Session « JPA Q&A

1. Why does Hibernate seem to be designed for short lived sessions?

I know this is a subjective question, but why does Hibernate seem to be designed for short lived sessions? Generally in my apps I create DAOs to abstract my data ...

2. org.hibernate.Session.clear() considered Harmful?

This is a design question, concrete code not submitted to protect my bottom. When working with Hibernate the standard workflow is as follows:

  1. Open Session
  2. Start Transaction
  3. Do the business (read and modify data)
  4. Commit Transaction
  5. Close ...

3. Is open/close hibernate session in every business logic a good design?

We are building a struts application using Hibernate (so we are relatively newbies to Hibernate). My question is with reference to the Hibernate session. Is it mandatory to close a session every time we open it? I mean, at the end of every action (or business logic to be precise) , should I 'manually close the session (close())? Isn't too 'expensive'? ...

4. session lost between two thread , bad design?

Hi, I try to work on a legacy application and turn it into a hibernate+jpa driven project from a pure jdbc one. But I have some questions right now, i use hibernate.current_session_context_class=thread as session manager but the session goes out between two thread, and I can't not pass bean between then. One solution i can think is that i detach all ...

5. Design question/Session lifetime

Hi, I've got the following situation: - on application startup a list of user objects got fetched from the database - later a meeting object got fetched from the database, containing a list of attending users. These users are other user objects than the ones loaded on startup, because the meeting got loaded in its own session. - now the meeting ...

6. SessionFactoryImpl - Design Question