> 1) is it possible to add another column to have a ParentHiearchyId that the > FK relationship could use? this would eliminate the problem completely, and > keep your approach otherwise the same. > No I have no control on Database.
> 2) How is ItemId generated? is it unique? (can you make it unique?) The > relationships you've shown above don't say anything either way about the > uniqueness of this column, but if it already is unique or if it's an option, > I'd very strongly recommend switching to using ItemId and ParentItemId as > non-composite id keys, and just having HierarchyId in as a required field. > besides eliminating your problem, it would also mean you don't have to deal > with the *myriad* additional complexities of composite keys. > ItemId is not unique among entire table. A pair HierarchyId, ItemId is unique. It's a bit old-fashioned Db design but unfortunatelly I can not do anything with this. > > On Tue, Jan 19, 2010 at 5:06 AM, Petr Syromolotov < > [email protected]> wrote: > >> Well this does not solve my problem. >> >> >> <class name="HierarchyItem"> >> <composite-id > >> <key-many-to-one name="Hierarchy" column="HierarchyId"/> >> >> <key-property name="ItemId" column="ItemId"/> >> </composite-id> >> >> <many-to-one name="ParentItem" class="HierarchyItem"> >> <column name="HierarchyId" /> >> <column name="ParentItemId" /> >> </many-to-one> >> </class> >> >> I still have column HierarchyId specified twice. >> It would be great to have something like <column-many-to-one> or <column >> insert="false" update="false/> instead of <column name="HierarchyId" />. >> >> Peter >> >> >> On Tue, Jan 19, 2010 at 1:34 PM, Gigi <[email protected]> wrote: >> >>> I think you should use <key-many-to-one /> in the <id/> and remove the >>> <many-to-one name="Hierarchy" ... /> >>> Then you will access Hierarchy through the Id. >>> >>> On 19 Gen, 10:28, Petr Syromolotov <[email protected]> wrote: >>> > Hello >>> > >>> > I have following mapping: >>> > >>> > <class name="HierarchyItem"> >>> > <composite-id > >>> > <key-property name="Hierarchy" column="HierarchyId"/> >>> > <key-property name="ItemId" column="ItemId"/> >>> > </composite-id> >>> > >>> > <many-to-one name="Hierarchy" column="HierarchyId" insert="false" >>> > update="false"></many-to-one> >>> > >>> > <many-to-one name="ParentItem" class="HierarchyItem"> >>> > <column name="HierarchyId" /> >>> > <column name="ParentItemId" /> >>> > </many-to-one> >>> > </class> >>> > >>> > The problem is that this mapping does not work - it generates >>> > "IndexOutOfRangeException" because columns "HierarchyId" is specified >>> twice. >>> > I can not put insert="false" update="false" to second <many-to-one> >>> tag. >>> > Is there any way to specify these options (insert="false" >>> update="false") >>> > only for <column name="HierarchyId" /> but not to entire >>> <many-to-one> >>> > tag? >>> > >>> > PS I know that DB design is not good here but I can't do anything with >>> this. >>> >>> -- >>> 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. >>> >>> >>> >>> >> >> -- >> 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. >> >> > > -- > 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. > >--
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.
