Considering the peculiar errors you get I'ld say the main problem
isn't in the mappings, but in how you use the classes.

/Oskar


Den 11 april 2012 20:02 skrev Simon Bond <[email protected]>:
> Hi,
>
> I'm trying to set up a one-to-many relationship and am failing to get it to
> work correctly.
>
> I have a table 'ParentEntity' that can point to one or more 'ChildEntity'
> records.
> -- parent entity mapping --
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> assembly="DataAccessLibrary" namespace="DataAccessLibrary.Core">
>     <class name="ParentEntity">
>         <id name="Id">
>             <generator class="increment"/>
>         </id>
>         <list name="Children">
>             <key column="ParentEntityId" />
>             <index column="ChildIndex"/>
>             <one-to-many class ="ChildEntity"/>
>         </list>
>     </class>
> </hibernate-mapping>
>
> -- child entity mapping --
> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
> assembly="DataAccessLibrary" namespace="DataAccessLibrary.Core">
>     <class name="ChildEntity">
>         <id name="Id">
>             <generator class="increment"/>
>         </id>
>         <property name="Child" not-null="true"/>
>     </class>
> </hibernate-mapping>
>
> The first parent entry links to a child entity, however, when a second
> parent entity the first record loses its child.
>
> This is giving me the error 'No row with the given identifier
> exists[DataAccessLibrary.Core.ChildEntity#1]'
> If I add 'Cascade='add-delete-orphan' to the mapping in parentEntity I get
> 'A collection with cascade="all-delete-orphan" was no longer referenced by
> the owning entity instance:'.
>
> How should I go about specifying the relationship between these tables?
> Thanks
>
> --
> You received this message because you are subscribed to the Google Groups
> "nhusers" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/nhusers/-/p0nC3efjHhwJ.
> 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.

-- 
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