Виртуальная песочница (тм)

Tuesday, August 5, 2008

Transaction management and JPA

"My current project is a web application with Struts in the web tier, a stateless session EJB (EJB3) in the middle tier and various entity pojos (JPA) that model the data. The application server is JBoss 4.2.0.CR2 that uses Hibernate as the persistence provider.

In this configuration with container-managed transactions, the transaction boundary is the EJB method call. Struts action classes make calls to the session EJB methods in order to retrieve data for display in various JSPs. The problem is that after the EJB method returns, the transaction is over, the persistence context has ended and the POJOs returned are detached. If the JSP that displays the data tries to access any lazily loaded associations an exception occurs."

No comments: