-->
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: Unexpected row count: 0 expected: 1
PostPosted: Tue Sep 20, 2005 11:43 am 
Newbie

Joined: Tue Sep 20, 2005 11:20 am
Posts: 5
I have a java object, which holds a collection of people. When I insert these people into the database, I need to generate the key myself in my own code, since it is kind of complex and comes from a tabe with multiple columns that need to be looked at. For some reason, it wants to update the record, even though it is a brand new record that should be inserted instead. My object that holds the collection defines the collection like this:
Code:
<set name="witnesses" lazy="true"
      cascade="none" where="PERSON_TYPE_CD='WI'">
        <meta attribute="field-description">
           @hibernate.set
            lazy="true"
            inverse="true"
            cascade="none"

           @hibernate.collection-key
            column="RB_NUMBER"

           @hibernate.collection-one-to-many
            class="org.dotcomm.opd.valueobjects.Person"
        </meta>
        <key>
            <column name="RB_NUMBER" />
        </key>
        <one-to-many class="org.dotcomm.opd.valueobjects.Person" />
    </set>

My Id for the person is defined like this:
Code:
<id
        name="incidentPersonId"
        type="java.lang.Integer"
        column="INCIDENT_PERSON_ID"
unsaved-value="undefined"
    >
        <meta attribute="field-description">
           @hibernate.id
            generator-class="assigned"
            type="java.lang.Integer"
            column="INCIDENT_PERSON_ID"

        </meta>
        <generator class="assigned" />
    </id>

From everything I have read, this is the correct way to do it, and I have other "person" objects that are not Sets that are inserting fine, but when I have a set, it blows up. with this error...

[9/20/05 10:27:11:046 CDT] 63e063e0 SystemOut O Hibernate: update EIS001.INCIDENT_PERSON set RB_NUMBER=? where INCIDENT_PERSON_ID=?
[9/20/05 10:27:11:078 CDT] 63e063e0 AbstractFlush E org.hibernate.event.def.AbstractFlushingEventListener Could not synchronize database state with session
[9/20/05 10:27:11:546 CDT] 63e063e0 AbstractFlush E org.hibernate.event.def.AbstractFlushingEventListener TRAS0014I: The following exception was logged org.hibernate.HibernateException: Unexpected row count: 0 expected: 1

Can anyone help me? I am totally new to hibernate, and I have a tight deadline on this project.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Sep 20, 2005 12:00 pm 
Pro
Pro

Joined: Fri Sep 02, 2005 4:21 am
Posts: 206
Location: Vienna
Did you have a look at http://www.jroller.com/comments/maximdim/Weblog/hibernate_batch_update_returned_unexpected or
http://blogs.warwick.ac.uk/colinyates/entry/hibernate_and_their_1/?

Maybe you'll find a hint there.

Erik


Top
 Profile  
 
 Post subject: I figured it out.
PostPosted: Tue Sep 20, 2005 4:15 pm 
Newbie

Joined: Tue Sep 20, 2005 11:20 am
Posts: 5
After looking into this some more, I made a change that made this work. Note the cascade="all" needed to be set.
Code:
<set name="witnesses" lazy="true"
      cascade="all" where="PERSON_TYPE_CD='WI'">
        <meta attribute="field-description">
           @hibernate.set
            lazy="true"
            inverse="true"
            cascade="none"

           @hibernate.collection-key
            column="RB_NUMBER"

           @hibernate.collection-one-to-many
            class="org.dotcomm.opd.valueobjects.Person"
        </meta>
        <key>
            <column name="RB_NUMBER" />
        </key>
        <one-to-many class="org.dotcomm.opd.valueobjects.Person" />
    </set>


Thanks for the help however.


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.