-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Cannot rollback transaction in tomcat 5.0.28
PostPosted: Sun Jan 23, 2005 12:31 am 
Newbie

Joined: Sun Dec 19, 2004 8:11 am
Posts: 7
i have no idea at all why I can't rollback my transaction.....

Hibernate version:
2.1.7

Hibernate config:
<session-factory>

<!-- hibernate.connection.provider_class net.sf.hibernate.connection.C3P0ConnectionProvider -->
<property name="c3p0.min_size">2</property>
<property name="c3p0.max_size">10</property>
<property name="c3p0.max_statements">100</property>
<property name="c3p0.timeout">100</property>
<property name="c3p0.validate">true</property>

<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
<property name="connection.url">
jdbc:mysql://localhost:3306/testDB?autoReconnect=true&amp;relaxAutoCommit=true&amp;useUnicode=true&amp;characterEncoding=utf-8
</property>
<property name="connection.username">***</property>
<property name="connection.password">***</property>
<property name="show_sql">true</property>
<property name="dialect">
net.sf.hibernate.dialect.MySQLDialect
</property>
<property name="transaction.factory_class">
net.sf.hibernate.transaction.JDBCTransactionFactory
</property>

<!-- Mapping files -->
<mapping resource="Member.hbm.xml" />

</session-factory>

Code between sessionFactory.openSession() and session.close():
try {
Session session = HibernateUtil.currentSession();
logger.debug("begin transaction");
Transaction tx = session.beginTransaction();
session.connection().setAutoCommit(false);

primaryKey = (Integer) session.save(member);

logger.debug("try to rollback transaction");
// cannot rollback
tx.rollback();

// tried this one but not success
//session.connection().rollback();

HibernateUtil.closeSession();
}

catch (HibernateException he) {
logger.error(he.toString());
}
catch (Exception e) {
logger.error(e);
}

Name and version of the database you are using:
MySQL 4.0.18.

Debug level Hibernate log excerpt:
2005-01-23 12:11:44,015 [INFO] Configuration doConfigure - Configured SessionFactory: null
2005-01-23 12:11:44,015 [INFO] Configuration secondPassCompile - processing one-to-many association mappings
2005-01-23 12:11:44,015 [INFO] Configuration secondPassCompile - processing one-to-one association property references
2005-01-23 12:11:44,015 [INFO] Configuration secondPassCompile - processing foreign key constraints
2005-01-23 12:11:44,125 [INFO] Dialect <init> - Using dialect: net.sf.hibernate.dialect.MySQLDialect
2005-01-23 12:11:44,171 [INFO] SettingsFactory buildSettings - Maximim outer join fetch depth: 2
2005-01-23 12:11:44,171 [INFO] SettingsFactory buildSettings - Use outer join fetching: true
2005-01-23 12:11:44,187 [INFO] C3P0ConnectionProvider configure - C3P0 using driver: com.mysql.jdbc.Driver at URL: jdbc:mysql://localhost:3306/frdscafe?autoReconnect=true&relaxAutoCommit=true&useUnicode=true&characterEncoding=utf-8
2005-01-23 12:11:44,187 [INFO] C3P0ConnectionProvider configure - Connection properties: {user=system, password=password}
2005-01-23 12:11:44,343 [INFO] TransactionFactoryFactory buildTransactionFactory - Transaction strategy: net.sf.hibernate.transaction.JDBCTransactionFactory
2005-01-23 12:11:44,359 [INFO] TransactionManagerLookupFactory getTransactionManagerLookup - No TransactionManagerLookup configured (in JTA environment, use of process level read-write cache is not recommended)
Initializing c3p0 pool... com.mchange.v2.c3p0.PoolBackedDataSource@a193fe [ connectionPoolDataSource -> com.mchange.v2.c3p0.WrapperConnectionPoolDataSource@2e6c66 [ acquireIncrement -> 1, autoCommitOnClose -> false, connectionTesterClassName -> com.mchange.v2.c3p0.impl.DefaultConnectionTester, factoryClassLocation -> null, forceIgnoreUnresolvedTransactions -> false, idleConnectionTestPeriod -> 0, initialPoolSize -> 2, maxIdleTime -> 100, maxPoolSize -> 10, maxStatements -> 100, minPoolSize -> 2, nestedDataSource -> com.mchange.v2.c3p0.DriverManagerDataSource@1fb2ef9 [ description -> null, driverClass -> null, factoryClassLocation -> null, jdbcUrl -> jdbc:mysql://localhost:3306/frdscafe?autoReconnect=true&relaxAutoCommit=true&useUnicode=true&characterEncoding=utf-8, properties -> {user=system, password=password} ] , propertyCycle -> 300, testConnectionOnCheckout -> true ] , factoryClassLocation -> null, numHelperThreads -> 3 ]
2005-01-23 12:11:45,140 [INFO] SettingsFactory buildSettings - Use scrollable result sets: true
2005-01-23 12:11:45,140 [INFO] SettingsFactory buildSettings - Use JDBC3 getGeneratedKeys(): true
2005-01-23 12:11:45,140 [INFO] SettingsFactory buildSettings - Optimize cache for minimal puts: false
2005-01-23 12:11:45,140 [INFO] SettingsFactory buildSettings - echoing all SQL to stdout
2005-01-23 12:11:45,156 [INFO] SettingsFactory buildSettings - Query language substitutions: {}
2005-01-23 12:11:45,156 [INFO] SettingsFactory buildSettings - cache provider: net.sf.hibernate.cache.EhCacheProvider
2005-01-23 12:11:45,171 [INFO] Configuration configureCaches - instantiating and configuring caches
2005-01-23 12:11:45,609 [INFO] SessionFactoryImpl <init> - building session factory
2005-01-23 12:11:46,703 [INFO] SessionFactoryObjectFactory addInstance - Not binding factory to JNDI, no JNDI name configured
2005-01-23 12:11:46,703 [INFO] HibernateUtil currentSession - Return current session
2005-01-23 12:11:46,875 [DEBUG] MemberDAO addMember - begin transaction
Hibernate: insert into MEMBER (password, mem_nickname) values (?, ?)
2005-01-23 12:11:47,000 [DEBUG] MemberDAO addMember - try to rollback transaction
2005-01-23 12:11:47,015 [DEBUG] TestAction execute - primaryKey: 35
2005-01-23 12:11:47,015 [DEBUG] TestAction execute - ended


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 23, 2005 7:51 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Need to use InnoBD tables for transactions to work in MySQL.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.