Search code examples
javahibernatejakarta-eejpaseam2

JBoss Seam: How to Open jpa/hibernate session in view


There is a similar question for Spring.

But what about JBoss Seam, I need a suggestion regarding the application I am developing.

If you need any specific version information, they are

  • Seam 2.2
  • JSF 1.2
  • JPA 1 and Hibernate as persistence provider

Solution

  • Check out the seam documentation related to persistence contexts.

    http://docs.jboss.org/seam/2.2.0.GA/reference/en-US/html/persistence.html#persistence.seam-managed-persistence-contexts

    Essentially, you register the persistence context with seam and inject the EntityManager into your bean. You can associate the context with a conversation to keep the session open across multiple requests by setting the flushMode in the @Begin annotation (@Begin and @End control conversations).