-->
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.  [ 9 posts ] 
Author Message
 Post subject: Rolling back potentially unresolved txn...
PostPosted: Tue Dec 07, 2004 5:05 am 
Beginner
Beginner

Joined: Wed May 05, 2004 3:26 am
Posts: 25
I read on this post that when this message shows up it means that the program does not call commit, rollback or setAutoCommit prior to close. However as you can see here I do call the tx.commit() and stil get the message.
Also, can you please elaborate me as on why I constantly get the database "changed to" WARNing messages?

Thanks in advance.

Hibernate version: 2.1.4

Code between sessionFactory.openSession() and session.close():
Code:
      Session session = getClientSession();
      Transaction tx = null;
      List result;
      
      try
      {                     
         tx = session.beginTransaction();
         
         Query sqlQuery = session.getNamedQuery(query);
         
         if(params != null)
            for(Iterator keys = params.keySet().iterator(); keys.hasNext();)
            {
               String param = (String)keys.next();
               Object value = params.get(param);
            
               sqlQuery.setParameter(param,value);
            }
         
         result = sqlQuery.list();
      }
      catch (HibernateException e)
      {
         Logger.error(e.getMessage());
         e.printStackTrace();
         session.clear();
         result = null;
      }
      finally
      {
         
         try
         {
            if(tx != null)
               tx.commit();
         }
         catch (HibernateException e1)
         {
            try
            {
               tx.rollback();
            }
            catch (HibernateException ignore) {}
            
            Logger.error(e1.getMessage());
            e1.printStackTrace();
         }
         closeSession();


Name and version of the database you are using:
Microsoft SQL Server 2000 - 8.00.760


Debug level Hibernate log excerpt:
Code:
HIBERNATE: WARN  - SQL Warning: 0, SQLState:
HIBERNATE: WARN  - [Microsoft][SQLServer 2000 Driver for JDBC]Database changed to os
HIBERNATE: WARN  - SQL Warning: 0, SQLState:
HIBERNATE: WARN  - [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed database context to 'os'.
HIBERNATE: WARN  - SQL Warning: 0, SQLState:
HIBERNATE: WARN  - [Microsoft][SQLServer 2000 Driver for JDBC]Language changed to ελληνικά
HIBERNATE: WARN  - SQL Warning: 0, SQLState:
HIBERNATE: WARN  - [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Changed language setting to ελληνικά.
Rolling back potentially unresolved txn...

_________________
The Bits Control The Atoms


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 5:37 am 
Beginner
Beginner

Joined: Tue Oct 26, 2004 12:45 pm
Posts: 43
Location: Israel
Hi.

As i understarnd it, the default database when you log on to MSSQL is "Master", so whenever you work on a different DB, it switches to it, and maybe switch back when you disconnect.

about the commit():

Try to move the commit() indise the try, in the end ot it.
as i see here, you might call commit even if exception was thrown.

it should be like that:

Code:
try
{
//    ... do your stuff

    tx.commit();
}
catch(HibernateException e)
{
    tx.rollback()
}
finally
{
     session.close();
}


this way, not commit will happen if exception was thrown.

please try, and post your results.

Jus.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 6:13 am 
Beginner
Beginner

Joined: Wed May 05, 2004 3:26 am
Posts: 25
Hey thanks for the tip!
Its great to receive feedback from fellow users.

It does seem however that this does not solve the problem with the txn...

As with the default db, I guess then that the messages aren't of great concern.

_________________
The Bits Control The Atoms


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 6:26 am 
Beginner
Beginner

Joined: Tue Oct 26, 2004 12:45 pm
Posts: 43
Location: Israel
mcueh wrote:
Its great to receive feedback from fellow users.


yeah, it is great... :)
Quote:
It does seem however that this does not solve the problem with the txn...


please post you hibernate.cfg.xml, maybe something is wrong with the definition of the transaction or sessionFactory.

when you debug, what is the type of the Transaction object?

Jus.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 6:38 am 
Beginner
Beginner

Joined: Wed May 05, 2004 3:26 am
Posts: 25
The type is JDBCTransaction.

hibernate.cfg.xml
Code:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD//EN" "http://hibernate.sourceforge.net/hibernate-configuration-2.0.dtd">
<hibernate-configuration>
                <session-factory>

<!-- c3p0 connection pool -->
                <property name="c3p0.acquire_increment">1</property>
                <property name="c3p0.idle_test_period">100</property>
                <property name="c3p0.max_size">100</property>
                <property name="c3p0.max_statements">0</property>
                <property name="c3p0.min_size">10</property>
                <property name="c3p0.timeout">100</property>

                <property name="hibernate.connection.url">jdbc:microsoft:sqlserver://[host]:[port]</property>
                <property name="hibernate.connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
                <property name="hibernate.connection.username">[user]</property>
                <property name="hibernate.connection.password">[password]</property>

                <property name="show_sql">false</property>

                <property name="dialect">net.sf.hibernate.dialect.SQLServerDialect</property>
                <property name="hibernate.cache.provider_class">net.sf.hibernate.cache.HashtableCacheProvider</property>


//some mappings

       </session-factory>
</hibernate-configuration>



_________________
The Bits Control The Atoms


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 07, 2004 7:53 am 
Beginner
Beginner

Joined: Tue Oct 26, 2004 12:45 pm
Posts: 43
Location: Israel
mcueh wrote:
The type is JDBCTransaction.


Sorry, but I can't find any flows... :)

you'll have to debug inside the JDBCTransaction, and see what happens there.

Jus.


Top
 Profile  
 
 Post subject: Re: Rolling back potentially unresolved txn...
PostPosted: Wed Dec 08, 2004 12:44 pm 
jTDS Developer
jTDS Developer

Joined: Tue Feb 24, 2004 5:36 pm
Posts: 70
Location: Bucharest, Romania
The reason you see the warnings is that SQL Server itself generates those messages as warnings. There's nothing you can do about it and nothing to worry about (if you create a simple Connection to SQL Server and call getWarnings() on it immediately after you'll see the same messages).

The "Rolling back..." part is a bit more difficult. It could be caused by the fact that the MS driver doesn't really support transactions unless you specify "selectMode=cursor" or something like that in the URL. And then you will have performance problems. The MS driver is not recommended to be used with Hibernate, anyway.

Alin,
jTDS Project member.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 09, 2004 6:17 am 
Beginner
Beginner

Joined: Wed May 05, 2004 3:26 am
Posts: 25
Right...thanks for the update.
So which driver should I use? :/

_________________
The Bits Control The Atoms


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 09, 2004 7:48 am 
jTDS Developer
jTDS Developer

Joined: Tue Feb 24, 2004 5:36 pm
Posts: 70
Location: Bucharest, Romania
As a jTDS developer I would obviously recommend it as a good choice. You could also try one of the commercial drivers for SQL Server if you can afford it.

Take a look at the Hibernate Compatibility Guide & Supported Databases for a more complete view of the problem.

Alin.


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