-->
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.  [ 2 posts ] 
Author Message
 Post subject: In Hibernate - Update record gives exception
PostPosted: Wed Mar 16, 2011 5:44 am 
Newbie

Joined: Wed Mar 16, 2011 5:17 am
Posts: 1
I have two tables in a same schema,One with current data and other with archived data,When there is an input ,It will update in current data table and writes in Archived data table
When I do this I am getting an error in Postgresql


The error message in given below

org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1

Kindly help me to resolve this issue


Top
 Profile  
 
 Post subject: Re: In Hibernate - Update record gives exception
PostPosted: Wed Mar 16, 2011 10:18 am 
Beginner
Beginner

Joined: Mon Nov 15, 2010 10:39 am
Posts: 27
So you have 2 tables mapped to the same persistence class?

Or do you have 1 persistent class for archived, and 1 for current?

If you use the last approach (with 2 persistent classes that are basically the same.), then this could be done by something like this:

public void updateCurrent(Current c, SomeProperty toBeUpdated) {

//open session, get transaction, etc
Archived a = new Archived();
a.setSomeProperty1(c.getSomeProperty1);
a.setSomeProperty2(c.getSomeProperty2);
//do this for all properties
c.setSomeProperty(toBeUpdated);
session.saveOrUpdate(c);
session.save(a);
//commit, close transaction etc.
}

Might not be the most elegant way to do it, but kinda hard when you don't specify exactly what you want to do..


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 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:
cron
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.