-->
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.  [ 4 posts ] 
Author Message
 Post subject: SaveOrUpdate Method in Web Applications - How to use it?
PostPosted: Thu Sep 14, 2006 9:31 am 
Senior
Senior

Joined: Fri Jan 13, 2006 2:50 pm
Posts: 123
Location: Blumenau / SC / Brasil
Hi!

I would like to know how do you use SaveOrUpdate method in Web Applications. I can't see how to use this method :(

Every time I have one status that says: Updating or Inserting. So, everytime too, I test this status and call Save or Update.

Can you show some sample? :-)

Tks


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 9:51 am 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
SaveOrUpdate uses the unsaved-value attribute in the mapping file (<id>) to determine if an insert or update is required.

For example, I always use an unsaved value of -1 for the primary key and set the initial value of the primary key field to -1 in the constructor. Now when NHibernate gets called with SaveOrUpdate() and it finds -1 as the primary key value, it knows that an insert has to be performed and no update.

_________________
Cuyahoga


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 10:59 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
martijnb wrote:
SaveOrUpdate uses the unsaved-value attribute in the mapping file (<id>) to determine if an insert or update is required.


Correct is "SaveOrUpdate uses the unsaved-value attribute in the mapping file (<id>, <version> or <timestamp>) to determine if an insert or update is required. "

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Sep 14, 2006 12:53 pm 
Senior
Senior

Joined: Sat May 14, 2005 8:40 am
Posts: 130
gert wrote:
martijnb wrote:
SaveOrUpdate uses the unsaved-value attribute in the mapping file (<id>) to determine if an insert or update is required.


Correct is "SaveOrUpdate uses the unsaved-value attribute in the mapping file (<id>, <version> or <timestamp>) to determine if an insert or update is required. "


Indeed you're right. When typing this, I already had a slight feeling that I was missing something :). Thanks for pointing this out.

_________________
Cuyahoga


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