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: Error after "save" and "commit"
PostPosted: Tue Nov 06, 2007 6:14 am 
Newbie

Joined: Tue Oct 30, 2007 10:53 am
Posts: 8
Location: Luxemburg
Hi!

I'm new to hibernate and just wrote myself a little test application. It nearly works, i can read data out of the db and save changes, but when i try to insert a new data, I get this error when doing the commit:

Code:
SQL insert, update or delete failed (expected affected row count: 1, actual affected row count: 0). Possible causes: the row was modified or deleted by another user, or a trigger is reporting misleading row count


I'm sure the problem has to do with my identifier, but can't figure out what's wrong.

Code:
<id name="Id" column="PERSONID" type="Int32">
    <generator class="assigned" />
</id>


In the class and the db (oracle) it is an integer. I use this to save or update the values:

Code:
    public void savePerson(Person pers)
    {
        ISession session = factory.OpenSession();
        ITransaction tx = session.BeginTransaction();

            session.SaveOrUpdate(pers);                     
            tx.Commit();
            session.Close();


Works perfectly for an update, but sucks for the "insert". Does anybody have an idea where my mistake is?

Thanks for any help,

Martin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 06, 2007 12:42 pm 
Hibernate Team
Hibernate Team

Joined: Tue Jun 13, 2006 11:29 pm
Posts: 315
Location: Calgary, Alberta, Canada
When the id generator is "assigned", SaveOrUpdate() will always update. See docs:
http://www.hibernate.org/hib_docs/nhibe ... d-assigned

_________________
Karl Chu


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:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.