-->
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: Best way to update with Hibernate?
PostPosted: Tue May 18, 2004 3:25 pm 
Beginner
Beginner

Joined: Sun May 16, 2004 3:53 pm
Posts: 47
Location: Belo Horizonte, Brazil
Hi,
if my client (swing, web, etc...) wants to update a Person, do i need to load the Person so i can update it?

Suppose the following code in my fa


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 3:49 pm 
Regular
Regular

Joined: Wed May 05, 2004 3:41 pm
Posts: 118
Location: New Jersey,USA
Yes. However if the object was loaded previously for displaying the info to your UI you probably do not require to load the object again.

Even if you are forced to load the object if you set you Data cache correctly the performance might not be impacted.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 4:18 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
No, you don't have to load the object, you can just do session.update(p1)


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 5:37 pm 
Beginner
Beginner

Joined: Sun May 16, 2004 3:53 pm
Posts: 47
Location: Belo Horizonte, Brazil
Michael,
just doing session.update() doesn't work for me.

It simply doesn't understand that is the same object (and it actually is, i made myself sure of it specifying the correct id).

It's clear when i use saveORupdate method, hibernate creates another object (as my table is using auto_increment, it simply ignores the id of my object and stores a new one in db) and doesn't update the other one.

What would be a explanation for this?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 18, 2004 5:39 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
Set unsaved-value, see documentation.

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


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.