-->
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.  [ 5 posts ] 
Author Message
 Post subject: save not saving...
PostPosted: Thu Apr 21, 2005 12:14 pm 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
I read the FAQ before I posted, and yes I've tried flushing the session and commiting the transaction but my object is not being saved to the database.

I'm using Hibernate3, the jTDS JDBC driver for SQL Server and M$ SQL Server.

Here's my code snippet:

// user is an object mapped via hibernate, search for said user
// works before we get to this code and we've updated the password
Session ds = GlobalData.sessionFactory.openSession();
Transaction t = ds.beginTransaction();
ds.update(user);
ds.flush();
t.commit();

Resulting object is not saved. Logs show this:

Apr 21 12:09:30 org.hibernate.SQL[DEBUG]: update kc2.dbo.users set role=?, password=?, email=?, firstName=?, lastName=?, giraffe=?, createDate=?, modifyDate=? where uuid=?
Apr 21 12:09:30 org.hibernate.jdbc.AbstractBatcher[DEBUG]: preparing statement
Apr 21 12:09:30 org.hibernate.jdbc.AbstractBatcher[DEBUG]: about to close PreparedStatement (open PreparedStatements: 1, globally: 1)
Apr 21 12:09:30 org.hibernate.jdbc.AbstractBatcher[DEBUG]: closing statement
Apr 21 12:09:30 org.hibernate.event.def.AbstractFlushingEventListener[DEBUG]: post flush
Apr 21 12:09:30 org.hibernate.transaction.CacheSynchronization[DEBUG]: transaction before completion callback
Apr 21 12:09:30 org.hibernate.jdbc.JDBCContext[DEBUG]: before transaction completion
Apr 21 12:09:30 org.hibernate.impl.SessionImpl[DEBUG]: before transaction completion
Apr 21 12:09:30 org.hibernate.transaction.CacheSynchronization[DEBUG]: transaction after completion callback, status: 3
Apr 21 12:09:30 org.hibernate.jdbc.JDBCContext[DEBUG]: after transaction completion
Apr 21 12:09:30 org.hibernate.impl.SessionImpl[DEBUG]: after transaction completion
Apr 21 12:09:30 org.hibernate.transaction.JTATransaction[DEBUG]: Committed JTA UserTransaction
Apr 21 12:09:30 org.hibernate.impl.SessionImpl[DEBUG]: closing session
Apr 21 12:09:30 org.hibernate.jdbc.AbstractBatcher[DEBUG]: closing JDBC connection (open PreparedStatements: 0, globally: 0) (open ResultSets: 0, globally: 0)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 21, 2005 12:19 pm 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
Sorry, I should have said: update not updating

TIA,

J --


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 21, 2005 5:14 pm 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
Actually... I've just added some more logging to make certain, but it appears the transaction is being automatically rolled back.

Any thoughts on why this might happen? There is not accompanying SQL error that would force my exception catch and corresponding rollback.

Instead, this rollback occurs right after the commit. Here's the code snippet:
{... from before}
tx.commit();
if (tx.wasCommitted())
log.debug("WOOOOOOOOOOOO!");
else
log.debug("WAAAAAAAAAANk!");

So, as you might guess, I'm getting a Wank in the log. Thoughts?

TIA,

J --


Top
 Profile  
 
 Post subject:
PostPosted: Thu Apr 21, 2005 9:30 pm 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
Have now also tried v3.0.1 of hibernate and have the same problem. Unless I set hibernate.connection.autocommit to true, any save/update is automatically rolled back.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Apr 22, 2005 8:06 am 
Beginner
Beginner

Joined: Wed Apr 20, 2005 9:30 am
Posts: 39
Since no one else replied to this, I'll post my own fix for those of you who might run into this same problem.

The solution was to use the Resin pooling and tie the DB connectivity to JNDI rather than instantiating some other cache programatically in the web app.

It's all set now...


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