-->
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: Update "rollback" - why?
PostPosted: Fri Dec 19, 2003 10:13 pm 
Newbie

Joined: Fri Dec 19, 2003 9:55 pm
Posts: 6
Hi!

I'm a bit puzzeled here... I'm trying to update a field that has previously been updated before, but it seems that Hibernate does a "rollback" after the session is closed. I'm having a hard time figuring out why.

Here's some log data:

[...]
DEBUG NullableType --> binding 'true' to parameter: 7
DEBUG NullableType --> binding 'false' to parameter: 8
DEBUG NullableType --> binding '2' to parameter: 9
DEBUG BatchingBatcher --> Adding to batch
DEBUG BatchingBatcher --> Executing batch size: 1
DEBUG BatchingBatcher --> success of batch update unknown: 0
DEBUG BatcherImpl --> done closing: 0 open PreparedStatements, 0 open ResultSets
DEBUG BatcherImpl --> closing statement
DEBUG SessionImpl --> post flush
DEBUG SessionImpl --> transaction completion
DEBUG SessionImpl --> closing session
DEBUG SessionImpl --> disconnecting session
DEBUG SessionImpl --> transaction completion
DEBUG SessionImpl --> object already associated with session
DEBUG JDBCTransaction --> commit
DEBUG SessionImpl --> flushing session
DEBUG SessionImpl --> Flushing entities and processing referenced collections
DEBUG AbstractEntityPersister --> hibernate.cats.name is dirty
DEBUG SessionImpl --> running Session.finalize()
DEBUG SessionImpl --> Updating entity: [hibernate.cats#2]
[...]



The following line could be interesting:
DEBUG AbstractEntityPersister --> hibernate.cats.name is dirty

I'm receiving no exceptions. If I exit just after the session is closed, then the "rollback" is not carried out.

Do I have to explicitly "close" persistent objects or something??

Any suggestions would be very welcome as my hair is getting thinner every minute...

Btw, here's a bit of the code I'm using to update the field:

-------------------------------------------------------------------

public void updateCatName(String newName, Integer id)
throws HibernateException
{
Session session = null;
Transaction tx = null;
try {
session = dbSessionFactory.openSession();
tx = session.beginTransaction();

Cats c = (Cats) session.load(Cats.class, id);
c.setName(newName);
session.update(m);

tx.commit();
}
catch (HibernateException hex) {
if (tx != null) tx.rollback();
throw new SMILRuntimeException(errMsg, hex);
}
finally {
session.close();
}
}

---------------------------------------------------------------------

/Jennifer


Top
 Profile  
 
 Post subject:
PostPosted: Mon Dec 22, 2003 4:41 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Hum puzzled too, Hibernate should flush your session when using net.sf.hibernate.Transaction.

Is newName actually a new name ?
Try to add a session.flush(); before the commit.

By the way, no need to call udapte on an object loaded by the same session. Update is usefull when associating a transiant object to the session.

_________________
Emmanuel


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.