-->
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.  [ 4 posts ] 
Author Message
 Post subject: Bag
PostPosted: Fri Jun 09, 2006 5:02 am 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
i'm trying to update a master/detail class but i always get this exception :

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.

C# MASTER definiotions of property details
---
private IList m_details;
public IList Details
{
get { return m_details; }
set { m_details = value; }
}
---
the exception was thown when i flush the session
C# code to save
---
this.m_session.SaveOrUpdate(this.Header);
this.m_session.Flush();
---
Hibernate version: 1.0.2

Mapping documents:
MASTER
---
<class name='CUP.Header, CUP' table='HEADER'>
<composite-id>
<key-property name='Year' column='PREANN' />
<key-property name='Number' column='PRENUM' />
</composite-id>
<property name='Type' column='PRETIP' />
<bag name='Details'>
<key>
<column name='PREANN' />
<column name='PRENUM' />
</key>
<one-to-many class='CUP.ReservationDetail, CUP' />
</bag>
</class>
---
DETAIL
---
<class name='CUP.Details, CUP' table='DETAILS'>
<composite-id>
<key-property name='Year' column='PREANN' />
<key-property name='Number' column='PRENUM' />
<key-property name='DetailRow' column='PRERIG' />
</composite-id>
<property name='ReservationDate' column='PREDAP' />
</class>

P.S: i remove useless properties.

Code between sessionFactory.openSession() and session.close():

Full stack trace of any exception that occurs:

Name and version of the database you are using: Oracle 10g

The generated SQL (show_sql=true):

Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject: Re: Bag
PostPosted: Fri Jun 09, 2006 5:25 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
berets wrote:
i'm trying to update a master/detail class but i always get this exception :

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.

DETAIL
---
<class name='CUP.Details, CUP' table='DETAILS'>
<composite-id>
<key-property name='Year' column='PREANN' />
<key-property name='Number' column='PRENUM' />
<key-property name='DetailRow' column='PRERIG' />
</composite-id>
<property name='ReservationDate' column='PREDAP' />
</class>



In case of composite key, NHibernate is unable to correctly dtermine if object is new instance or changed one. So, add <version> element to class mappings with appropriate unsaved-value attribute.

Gert

_________________
If a reply helps You, rate it!


Top
 Profile  
 
 Post subject: Re: Bag
PostPosted: Fri Jun 09, 2006 5:51 am 
Regular
Regular

Joined: Thu May 11, 2006 12:30 pm
Posts: 72
Quote:
In case of composite key, NHibernate is unable to correctly dtermine if object is new instance or changed one. So, add <version> element to class mappings with appropriate unsaved-value attribute.

Gert


in the header mapping or in the details mapping ? (or both?)
so i need to add an apposite field to my db table to manage versioning ?

thanks


Top
 Profile  
 
 Post subject: Re: Bag
PostPosted: Fri Jun 09, 2006 6:04 am 
Expert
Expert

Joined: Thu Jan 19, 2006 4:29 pm
Posts: 348
berets wrote:
in the header mapping or in the details mapping ? (or both?)
so i need to add an apposite field to my db table to manage versioning ?


I think that in details mapping might be sufficient. But I would suggest adding to both.

And yes, You'll need additional field in db tables.

Gert

_________________
If a reply helps You, rate it!


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