-->
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.  [ 4 posts ] 
Author Message
 Post subject: Rollback with C3P0 issued twice...
PostPosted: Thu Mar 03, 2005 11:30 am 
Newbie

Joined: Thu Mar 03, 2005 11:07 am
Posts: 6
Hibernate version:

2.1.7c

Mapping documents:

Code:
hibernate.cfg.xml :

...
<property name="connection.provider_class">net.sf.hibernate.connection.C3P0ConnectionProvider</property>
<property name="c3p0.min_size">5</property>
<property name="c3p0.max_size">20</property>
<property name="c3p0.timeout">300</property>
<property name="c3p0.max_statements">50</property>
<property name="c3p0.idle_test_period">3000</property>
...


Code of HibernateUtil

Code:
...
public static void rollbackTransaction()  {
    Transaction tx = (Transaction) threadTransaction.get();
    try {
      threadTransaction.set(null);
      if (tx != null && !tx.wasCommitted() && !tx.wasRolledBack()) {
        tx.rollback();
        closeSession();
      }
    } catch (HibernateException ex) {
      logger.error("Failed to rollback transaction: " + ex);
    }
}
...
public static void closeSession() {
    try {
      Session s = (Session) threadSession.get();
      threadSession.set(null);
      if (s != null) {
        s.close();
      }
    } catch (HibernateException ex) {
      logger.error("Failed to close Session object: " + ex);
    }
}
...


Name and version of the database you are using:

MySQL 4.1.7

The generated SQL as seen in the MySQL log:
Code:
insert into  ....
rollback
rollback


Hi!

When I enable the C3P0 Pool and a transaction rolls back (because of a constraint), the transaction is always rolled back twice. This does not happen if I use the default Hibernate connection pool. It's not a problem so far, but I was wondering why this is happening?

Thanks,
Jonas
[/code]


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 2:03 pm 
Regular
Regular

Joined: Thu Dec 18, 2003 2:14 am
Posts: 103
Location: Brooklyn, NY
Could you show the actual log output?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 03, 2005 2:24 pm 
Senior
Senior

Joined: Sun Jan 04, 2004 2:46 pm
Posts: 147
Connection pools usually rollback connections when they are returned to the pool ( when you call session.close() ) to ensure that there's no open transaction on it for when it is handed out next time.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 04, 2005 5:48 am 
Newbie

Joined: Thu Mar 03, 2005 11:07 am
Posts: 6
[quote="Myk"]Connection pools usually rollback connections when they are returned to the pool ( when you call session.close() ) to ensure that there's no open transaction on it for when it is handed out next time.[/quote]

Oh I see, so this is expected behaviour? Makes sense.

Thanks!
Jonas


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.