I have my DAO layer implemented using open JPA. My service
implementation code is made Transactional using the
Spring "@Transactional" annotation. I have my service test case extended
from the AbstractJpaTests and the test cases simulate detached objects
by ending a transaction and starting a new one. When ever I end a
transaction the Entity's stateManager instance is instance of
DetachedStateManager indicating it is detached entity. I merge the
detached entities and all test cases pass. When I integrate my service
code with the Web App I put the detached Entities on the Http Session
and merge them later but I get the EntityExistsException when merging
detached Entites. Also the stateManager instance is null, I would have
expected it to be DetachedStateManager.I am using the Spring frameworks
Transaction manager.
Below is my JPA config,
<!-- JPA Configuration Beans Wiring -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBea
n">
<property name="dataSource" ref="dataSource"/>
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.OpenJpaVendorAdapter">
<property name="showSql" value="false"/>
<property name="generateDdl" value="true"/>
<property name="databasePlatform"
value="org.apache.openjpa.jdbc.sql.OracleDictionary"/>
</bean>
</property>
<property name="jpaDialect">
<bean
class="com.inxight.mdr.core.jpa.OracleOpenJpaDialect"/>
</property>
<property name="loadTimeWeaver">
<bean
class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver"
/>
</property>
</bean>
<bean id="jpaTemplate"
class="org.springframework.orm.jpa.JpaTemplate">
<property name="entityManagerFactory"
ref="entityManagerFactory"/>
</bean>
<bean name="transactionManager"
class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory"
/>
<property name="dataSource" ref="dataSource"/>
</bean>
<tx:annotation-driven proxy-target-class="true"/>
If anyone is can shed some light on this issue it will be really
helpful.
Thanks,
Adish