-->
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.  [ 1 post ] 
Author Message
 Post subject: SaveOrUpdate and Contains
PostPosted: Wed Sep 06, 2006 11:40 am 
Newbie

Joined: Wed Sep 06, 2006 11:39 am
Posts: 1
I want the following functionality

1. I need to 'load' an object (let's say a person object with name Jack) in the session an object for validation
2. Need to 'saveOrUpdate' it later

It throws NonUniqueObjectException.

To avoid this I tried the following

1. first use currentsession.contains(thisinstance). If false, use saveOrUpdate. true, do nothing
- it didnt work. contains returns False in this case but saveOrUpdate fails subsequently.
2. used merge. Didnt work too. merger does not associate the instance to the session

Looks like, contains will return true only when the same instance is stored in the session and saveOrUpdate will throw exception even when different instances use same 'identifier' to be stored in the session.

what is the solution?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.