Sorry, but this thread seems quite confusing so far... Please consider the following:
Inheritance-mapping: Base class and a number of subclasses. You have ONE object, which may be of a subclass or of the baseclass. This may get persisted to one table, or spread out over several tables, but it is still ONE object. (Specifically: Spreading it out over several tables does not mean that you can later delete the row in one of the tables and expect that to be meaningful. It would be like deleting "half" of a C# object.) Parent-child-mapping: You have a parent class and a child class. The parent "owns" a child via a Parent.ChildProperty or multiple children via a collection property. This is a one-to-many relationship from parent to child, or possibly a one-to-one relationship if a parent can only have one child. Note that you have at least TWO objects here. In these cases it is perfectly fine to delete the child and keep the parent, but it is NOT inheritance mapping. So, which one is it that you want? Do you have a base class and a subclass, or do you have a parent class which owns objects of another, children, class? /Oskar 2010/2/2 Mind Works <[email protected]>: > Thanks for the reply. > > Is there a way to circumvent this. In the sense if we have a one-to- > many relationship mapped using the table-per-class struct then on > deleting one of the subclass the other subclass should not be deleted. > This would be on the lines of the way the relational data works. > > If we set the cascade property to none then we get the referential > error. One of the ways is to handle the error such that the parent > record does not get deleted. However this would be a work around and > not a solution. > > Kindly advise. > > Regards, Anil > > On Feb 2, 9:40 am, Fabio Maulo <[email protected]> wrote: >> The strategy you are talking about is: Table-per-class >> For sure when you delete a subclass the delete will happen in the subclass >> and in all its superclass because what you are deleting is an object >> instance where the state is spanned between more than one table. >> >> 2010/2/2 Mind Works <[email protected]> >> >> >> >> > Hi, >> >> > We have modeled the relationship between domain objects using the >> > table per subclass hierarchy structure. >> >> > The structure looks like: >> >> > Parent: >> >> > <?xml version="1.0" encoding="iso-8859-1"?> >> > <hibernate-mapping default-lazy="false" default-cascade="none" >> > xmlns="urn:nhibernate-mapping-2.2" > >> > <class name="ParentDO, TestProject1" table="TBLX" dynamic-insert >> > ="false" dynamic-update="false"> >> > <id name="ID" column="IDCol" type="System.Int64" unsaved-value="null"> >> > <generator class="sequence"> >> > <param name="sequence">SEQ01T</param> >> > </generator> >> > </id> >> > <version name="ver" column="ROWID" type="Int32" generated="never" >> > unsaved-value="null" /> >> > <property name="Xid" column="XID" type="System.Int64" >> > insert="true" update="true" /> >> > <property name="RowID" column="ROWID" type="System.String" >> > insert="false" update="false" /> >> > </class> >> > </hibernate-mapping> >> >> > The relationship has been mapped as follows: >> >> > <?xml version="1.0" encoding="iso-8859-1"?> >> > <hibernate-mapping default-lazy="false" default-cascade="none" >> > xmlns="urn:nhibernate-mapping-2.2"> >> > <joined-subclass name="Child, TestProject1" extends="ParentDO, >> > TestProject1" table="TBLY" > >> > <key column="CHILDID" foreign-key="PARENTID"/> >> > <property..../> >> > <property..../> >> > </joined-subclass> >> > </hibernate-mapping> >> >> > The delete cascade works as desired, however whenever we delete the >> > subclass the delete happens not only on the table to which the >> > subclass has been mapped, but also the root table and potentially >> > joined-subclass tables further down the inheritance hierarchy. >> >> > We have tried setting the dynamic-update and dynamic-insert properties >> > to false and also tried to set the cascade property to save-update, >> > none... The delete still moves up to the parent table. >> >> > Is this a known issue, or are we missing something. >> >> > Please help. >> >> > -- >> > 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]<nhusers%[email protected]> >> > . >> > For more options, visit this group at >> >http://groups.google.com/group/nhusers?hl=en. >> >> -- >> Fabio Maulo > > -- > 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. > > -- 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.
