-->
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: Update after Save doesn't show up in DB
PostPosted: Thu Mar 18, 2004 4:36 pm 
Newbie

Joined: Thu Mar 18, 2004 12:29 pm
Posts: 9
My first "real" test of hibernate has succeeded, but test #2 hasn't. I'm sure it's something I'm not understanding, but if someone could point it out, I'd sure appreciate it.

The code is essentially this:

Code:
HibTest x = new HibTest();
x.setStringVal("some string");
x.setFloatVal(10.0F);

Session sess = myFactory.openSession();
sess.saveOrUpdate(x); // this works, spits out sql, shows up in the db, etc
// after this, x.id is correctly set, too

x.setStringVal("new value");
sess.saveOrUpdate(x); // this does nothing, seemingly
sess.close();

// At this point, I have "some string" and 10 in the database for this row.



Pointers to my errors greatly appreciated. Hibernate 2.1, MySql 4.x.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 4:46 pm 
Newbie

Joined: Wed Feb 18, 2004 6:50 am
Posts: 6
Hello!

You can try flush() the session and commit() the connection.

Marcos

_________________
"If brute force don't resolve your problems... you aren't using enought"


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 4:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Do a session.flush() before the close or use the transaction API.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 5:21 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
what about commiting?

look at transaction examples.... you'll need it soon


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 18, 2004 9:54 pm 
Newbie

Joined: Thu Mar 18, 2004 12:29 pm
Posts: 9
delpouve wrote:
what about commiting?

look at transaction examples.... you'll need it soon


Yeah, I know; this was just a test to get me using it.

In any case, .flush() was the answer. Thanks all


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.