GlassFish, Spring, Eclipselink EntityManager [message #546971] |
Wed, 14 July 2010 14:50  |
Eclipse User |
|
|
|
I'm running in GlassFish 3.0.1 with EclipseLink 2.0 and Spring 3.0. I have a Stateless EJB that is also a WebService.
@Stateless
@TransactionAttribute(TransactionAttributeType.REQUIRED)
@Interceptors(SpringBeanAutowiringInterceptor.class)
@WebService(...)
@Service
My EJB calls into my Dao framework which is managed by Spring. I'm using Spring's JpaTemplate to provide Exception Translation. My Dao classes are defined as Transactional using Spring annotations. Also, to be able to inject an EntityManagerFactory into my Dao classes / JpaTemplate, I have to configure the Spring LocalContainerEntityManagerFactoryBean.
@Transactional(propagation = Propagation.REQUIRED)
And my Spring configuration is defined as follows:
<tx:jta-transaction-manager />
<tx:annotation-driven/>
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaVendorAdapter">
<property name="showSql" value="true" />
</bean>
</property>
<property name="jpaDialect">
<bean
class="org.springframework.orm.jpa.vendor.EclipseLinkJpaDialect" />
</property>
<property name="persistenceUnitName" value="my-pu"></property>
</bean>
<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor">
<property name="persistenceUnits">
<map>
<entry key="my-pu" value="persistence/survey-pu"/>
</map>
</property>
<property name="persistenceContexts">
<map>
<entry key="my-pu" value="persistence/survey-pu"/>
</map>
</property>
</bean>
My problem is that it appears that Transactions are not working correctly or as expected. When I perform a read for an object, if I perform the query a second time I get a different instance of the object. While the data is the same the objects are not. This tells me that each object is being read within a different transaction.
I'm struggling with getting the Container and Spring to play nicely with each other. I want my EntityManager to participate within a Global transaction that should be started by the container.
Has anyone ever tried this or been successful with getting these technologies playing together?
Thanks for the help...
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.12604 seconds