-->
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.  [ 3 posts ] 
Author Message
 Post subject: SaveOrUpdate() with composite key
PostPosted: Sun Sep 28, 2008 11:53 pm 
Newbie

Joined: Mon Aug 18, 2008 7:02 am
Posts: 6
Hi all,
I'm using SaveOrUpdate() in aspx page & Composite key is define in .hbm.xml file. When I retrive data it works fine but while calling SaveOrUpdate() it throws following error.
Anyone could please help me out for the same:

Error is :
a different object with the same identifier value was already associated with the session


Top
 Profile  
 
 Post subject:
PostPosted: Mon Sep 29, 2008 12:00 pm 
Expert
Expert

Joined: Mon Nov 26, 2007 2:29 pm
Posts: 443
poonam,

Try to avoid using saveOrUpdate.

What is happening is, in your application you are having already an object with the same ID, in a "persistent" state.

In the short term, try not calling that method at all, and see of your object is saved anyways at the end, when you flush the session or commit the transaction.
If this doesn't work, use merge() instead.

In the long term, take a good look at the meaning of "persistent", "transient" and "detached".
An article of mine here

http://hibernar.org/articulos_en/persis ... ethods.php

explains Hibernate persistence methods, and why, in general, using saveOrUpdate() is a bad idea.

_________________
Gonzalo Díaz


Top
 Profile  
 
 Post subject: SaveOrUpdate() error
PostPosted: Wed Oct 01, 2008 8:37 am 
Newbie

Joined: Mon Aug 18, 2008 7:02 am
Posts: 6
Hi gonzao_diaz,

Thanks for replay,
We have gone through article, it is really very helpfull, & my error was solved using merge(). But to delete object which method should I use?

Thanks


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