-->
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() method in hibernate
PostPosted: Wed Aug 04, 2004 5:55 pm 
Newbie

Joined: Wed Aug 04, 2004 5:48 pm
Posts: 2
Hi,

I have been trying to use the save or update method in hibernate. Here is what has happened so far:

1. I did a
net.sf.hibernate.Session session = HibernateUtil.currentSession();
Transaction transaction = session.beginTransaction();

.......

session.save(sentObject);

which inserts a new row in the DB without problems.

2. I changed the method from session.save() to session.saveOrUpdate(Object).

I get a :
Wed Aug 04 17:45:50 EDT 2004 ERROR [Thread-1] Could not synchronize database state with session
net.sf.hibernate.HibernateException: SQL insert, update or delete failed (row not found)

I have not changed any of the config files between the 2 steps. Can somone please explain as to why this is happening and what I need to correct the issue. I need to update the DB row if the row already exists.

I am using DB2 UDB as the back end DB.

Please help,

-- Kailas


Top
 Profile  
 
 Post subject:
PostPosted: Wed Aug 04, 2004 6:36 pm 
Beginner
Beginner

Joined: Thu Jul 22, 2004 2:15 pm
Posts: 35
what does your hbm look like?

how about some hibernate generated sql queries..

it seem like you are setting a valid indetifier key and then try to save or update, but your identifier is not the key you have specified for a new record.

more info would help debug it better

_________________
--------------------------------------------------
To code or not to code... Is that a question?
--------------------------------------------------
Pritpal Dhaliwal


Top
 Profile  
 
 Post subject: Re: saveOrUpdate() method in hibernate
PostPosted: Thu Aug 05, 2004 5:08 am 
Beginner
Beginner

Joined: Mon Aug 02, 2004 1:08 pm
Posts: 42
Check unsaved-value attribute of your identifier mapping.


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.