Atomikos Forum

JPA transcation rollback is not working

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)
 my Manager.java       
        insertuser()
        {
         //here we are getting transcation support from spring.
        
          business.insertuser();
        }
               
        business.java we are using one method insertuser() 
          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 our dao.java class we are using one method insertuser(Object entity)
   
    void insertDetails(Object entity)
      {
        this.getJpaTemplate().persist(entity);     
      }
     
      and our     orm.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 my persistence.xml file is
 
  <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>com.evolvus.common.model.TaUser</class>
          ---------
          ---------
          ---------
          <properties>
            <property name="hibernate.transaction.manager_lookup_class"
            value="com.atomikos.icatch.jta.hibernate3.TransactionManagerLookup"/>
            </properties>   
    </persistence-unit>
  </persistence>
  and i configured my jndi in  application/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.MysqlXADataSource" 
                      factory="com.mysql.jdbc.jdbc2.optional.MysqlDataSourceFactory"
                      url="jdbc:mysql://192.168.1.5:3306/shobWebSample"
                      explicitUrl="true"
                      pinGlobalTxToPhysicalConnection="true"
                      ></Resource>
                     
                      and my config file is
                      config.xml
                     
                      <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</beans:prop>
            </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.LocalContainerEntityManagerFactoryBean">
     <beans: property name="persistenceUnitName" value="shop" />
        <beans: property name="jpaVendorAdapter">
            <beans:bean
                class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
                <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>
    
    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.
maya Send private email
Wednesday, December 08, 2010
 
 

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics