Hello,

I try to delete an item of a collection inside a transaction. When I
flush the session I get this error because the class of the child
items is mapped with a composite Id.

the mapping file look like this:

  <class name="Shipping" table="shipping_methods" lazy="false">
    <id name="Id" column="id">
      <generator class="assigned" />
    </id>
     ...
    <bag name="Days" table="delivery_days" lazy="false" cascade="all-
delete-orphan">
      <key column="shipping_method"/>
      <one-to-many class="DeliveryDay" />
    </bag>

  </class>

  <class name="DeliveryDay" table="delivery_days" lazy="false">
    <!--http://journalofasoftwaredev.wordpress.com/2008/04/19/
nhibernate-exception-unexpected-row-count-0-expected-1/-->
    <composite-id unsaved-value="any">
      <key-property name="ShippingMethod" column="shipping_method" />
      <key-property name="Day" />
    </composite-id>
    ...
  </class>

I try with and without unsaved-value="any" on the composite-id tag
cascade="all-delete-orphan", cascade="all" and no cascade attribute on
the bag tag.
But I always get an error.
Depending on the cascade and unsaved-value attribute I get different
error messages.
With this mapping file I get this error : {"Unexpected row count: 0;
expected: 1"}
and it seems that the SQL sent to the database is an UPDATE statement
instead of a DELETE statement... very strange.
I also get sometimes this error when I try to add more than on item to
the collection : {"a different object with the same identifier value
was already associated with the session: DeliveryDays.DeliveryDay, of
entity: DeliveryDays.DeliveryDay"}

Does anyone know what I am doing wrong with composite-key ?

regards,

mathmax
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"nhusers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/nhusers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to