Hi all
I have done an application configuration using hybernate + JPA ,and atomikos for XA transcation management and spring 3.0 ,here every thing is working fine however insert operation, when exception is throwing the transcation should rollback,but it is not happening!!
here is a small flow for our application, in our manager level we are calling the businesss (here we are using Spring IOC)
business.java we are using one method insertuser()my Manager.java
insertuser()
{
//here we are getting transcation support from spring.
business.insertuser();
}
and our dao.java class we are using one method insertuser(Object entity)insertuser()
{
Tauser taUser=new Tauser();
taUser.setUsername("Maya");
taUser.setPassword("*****")
Dao.insertDetails(taUser);
throw new NullPointerException("checking transcation management"); // because of this exception throwing,it should rollback right,but its not happening.The property's are commiting in to the table.
}
and ourvoid insertDetails(Object entity)
{
this.getJpaTemplate().persist(entity);
}and my persistence.xml file isorm.xml
<entity class="TaUser" name="TaUser">
<table name="ta_user" />
<attributes>
<id name="userId">
<column name="USER_ID" />
<generated-value strategy="AUTO" />
</id>
<basic name="userName">
<column name="USER_NAME" length="50" />
</basic>
</attributes>
</entity>
and i configured my jndi in<persistence-unit name="shop" transaction-type="JTA">
<provider>org.hibernate.ejb.HibernatePersistence </provider>
<jta-data-source>java:comp/env/jdbc/shobWeb</jta-data-source>
<mapping-file>META-INF/orm.xml</mapping-file>
<class> TaUser</class>
---------
---------
---------
<properties>
<property name="hibernate.transaction.manager_lookup_class"
value="com.atomikos.icatch.jta.hibernate3.Transact ionManagerLookup"/>
</properties>
</persistence-unit>
</persistence>and my config file isapplication/meta_inf/context.xml
<Resource name="jdbc/shobWeb" auth="Container"
driverClassName="com.mysql.jdbc.Driver"
user="root"
password="root"
type="com.mysql.jdbc.jdbc2.optional.MysqlXADataSou rce"
factory="com.mysql.jdbc.jdbc2.optional.MysqlDataSo urceFactory"
url="jdbc:mysql://localhost:3306/shobWebSample"
explicitUrl="true"
pinGlobalTxToPhysicalConnection="true"
></Resource>
config.xml
where is the issue? Actually when i am trying to update some property in table then transcation is working fine (rollback and commit is happening ),but when i am trying to do insert operation rollback is not happening.<beans:bean id="Manager"
class="org.springframework.transaction.interceptor .TransactionProxyFactoryBean">
<beans: property name="transactionManager">
<beans: ref bean="transactionManager" />
</beans: property>
<beans: property name="target">
<beans: ref local=" ManagerTarget" />
</beans: property>
<beans: property name="transactionAttributes">
<beans: props>
<beans: prop key="*">PROPAGATION_REQUIRED</beansrop>
</beans: props>
</beans: property>
</beans: bean>
<beans: bean id="ManagerTarget"
class="Manager">
<beans: property name="Business" ref="Business" />
</beans: bean>
<beans: bean id="Business" class="PaymentsBusiness">
<beans: property name="Dao" ref=" Dao" />
</beans:bean>
<beans:bean id="Dao"
class=" Dao">
<beans: property name="jpaTemplate">
<beans: ref bean="jpaTemplate" />
</beans: property>
</beans:bean>
<beans:bean id="jpaTemplate" class="org.springframework.orm.jpa.JpaTemplate">
<beans: property name="entityManagerFactory">
<beans: ref bean="entityManagerFactory" />
</beans: property>
</beans:bean>
<beans: bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerE ntityManagerFactoryBean">
<beans: property name="persistenceUnitName" value="shop" />
<beans: property name="jpaVendorAdapter">
<beans:bean
class="org.springframework.orm.jpa.vendor.Hibernat eJpaVendorAdapter">
<beans: property name="generateDdl" value="false" />
<beans: property name="showSql" value="true" />
</beans: bean>
</beans: property>
<beans: property name="persistenceXmlLocation">
<beans :value>classpath:META-INF/persistence.xml</beans: value>
</beans: property>
</beans: bean>


rop>
Reply With Quote
