OpenEntityManagerInViewFilter works wrong iwth JTA transaction
I am developing an application with JPA, and JTA transactions using hibernate
Java 7
Spring 3.2
Hibernate 4.1.7
Atomikos 3.8.0
Tomcat 7.0.25
I use the OpenEntityManagerInViewFilter (Just for one of the persistence units. I don't access the other outside transactions) for every page, so that bean properties are acessible during JSP rendering.
I have to persistence units defined in persistence.xml. If i define transaction-type as "RESOURCE_LOCAL", every thing works ok, but when I define transaction-type as "JTA", i get LazyInitializationException when I access not initialized properties
So, this works ok
Code:
<persistence-unit name="Geiser" transaction-type="RESOURCE_LOCAL">
......
</persistence-unit>
<persistence-unit name="Orve" transaction-type="RESOURCE_LOCAL">
......
</persistence-unit>
This way it throws LazyInitializationException
Code:
<persistence-unit name="Geiser" transaction-type="JTA">
......
</persistence-unit>
<persistence-unit name="Orve" transaction-type="JTA">
......
</persistence-unit>
The cuestion is: Do I need to use transaction-type="JTA" for JTA to work properly or is enough with transaction-type="RESOURCE_LOCAL"?
In case I need to use transaction-type="JTA", how do I solve the problem with LazyInitializationException?