2 Replies Latest reply on Nov 29, 2007 8:03 AM by Petterson Paula

    Commiting after each statement (mysql)

    Petterson Paula Newbie

      Hi,

      I noticed that my app is commiting after each statement.

      Eg:

      tx.begin();
      //some persistent modification
      tx.rollback();
      tx.commit();
      


      The rollback does nothing.

      <Context
       debug="5"
       reloadable="true" crossContext="false">
       <Resource
       name="jdbc/myDB"
       auth="Container"
       type="javax.sql.DataSource"
       driverClassName="com.mysql.jdbc.Driver"
       defaulAutoCommit="false"
       factory="org.apache.tomcat.dbcp.dbcp.BasicDataSourceFactory"
       url="jdbc:mysql://localhos:3306/mydb?autoReconnect=true&autoCommit=false"
       validationQuery="select current_date"
       removeAbandoned="true"
       removeAbandonedTimeout="30"
       useNaming="true"
       logAbandoned="true"
       maxActive="5"
       maxIdle="5"
       maxWait="15000"
       username="xxxxxx"
       password="xxxxx"/>
      </Context>
      


      persistence.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <persistence xmlns="http://java.sun.com/xml/ns/persistence"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd"
       version="1.0">
       <persistence-unit name="myDatabase" transaction-type="RESOURCE_LOCAL">
       <provider>org.hibernate.ejb.HibernatePersistence</provider>
       <jta-data-source>java:comp/env/jdbc/myDB</jta-data-source>
       <properties>
      
       <property name="hibernate.hbm2ddl.auto" value="update"/>
       <property name="hibernate.show_sql" value="true"/>
       <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/>
       <property name="hibernate.connection.autocommit" value="false"/>
      <!-- <property name="hibernate.datasource" value="java:comp/env/jdbc/myDB"/> -->
       <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/>
       <property name="transaction.flush_before_completion" value="true"/>
       <property name="transaction.factory_class" value="org.hibernate.transaction.JDBCTransactionFactory"/>
       <!-- RESOURCE_LOCAL
       <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/>
       -->
       <!-- alternative
       <property name="jboss.entity.manager.factory.jndi.name"
       value="java:/coollectBookingEntityManagerFactory"/>
       -->
       </properties>
       </persistence-unit>
      </persistence>
      


      Any ideas?

      Thanks,

      Petterson