Yes, exactly the same problem. The fact that I'm not the only who encountered this problem gives me some hope that it will be resolved in the near future :)
On Aug 17, 3:17 am, Anne Epstein <[email protected]> wrote: > Sounds like you're running into the same bug I reported > here:http://nhjira.koah.net/browse/NH-1747 > > If this bug is a problem for you, it can't hurt to vote for/comment on > the bug there... > > > > On Sun, Aug 16, 2009 at 8:24 AM, hival<[email protected]> wrote: > > > I have a simple hierarchy of classes mapped with the "subclass + join" > > strategy: > > > <class name="A" abstract="true"> > > <id name="Id" column="a_id"> > > <generator class="native" /> > > </id> > > > <discriminator column="a_type" type="string" /> > > <property name="FieldA" column="a_field_a" /> > > > <subclass name="B" discriminator-value="B"> > > <join table="B"> > > <key column="b_id" /> > > <property name="FieldB" column="b_field_b" /> > > <many-to-one name="C" column="c_id" not-null="true" > > /> > > </join> > > </subclass> > > </class> > > > and another entity is supposed to contain a collection of the subclass > > B: > > > <class name="C"> > > <id name="Id" column="c_id"> > > <generator class="native" /> > > </id> > > > <set name="B" inverse="true" cascade="all-delete-orphan"> > > <key column="c_id" /> > > <one-to-many class="B" /> > > </set> > > </class> > > > I thought that NH would see that the foreign key of the collection > > belonged to the joined table B and would join tables B and C. But > > unfortunately NH didn't. The second try was to use may-to-many element > > with the intermediate table: > > > <set name="B" table="B" inverse="true" cascade="all-delete-orphan"> > > <key column="c_id" /> > > <many-to-many class="B" column="b_id" unique="true" /> > > </set> > > > It works but when loading the collection NH joins table B twice: first > > time to load an instance of class B and second time because of using > > many-to-may element. > > > /* load collection NHTest.Model.C.B */ SELECT > > b0_.c_id as c3_1_, > > b0_.b_id as b1_1_, > > b1_.a_id as a1_3_0_, > > b1_.a_field_a as a3_3_0_, > > b1_1_.b_field_b as b2_4_0_, > > b1_1_.c_id as c3_4_0_ > > FROM > > B b0_ > > left outer join > > A b1_ > > on b0_.b_id=b1_.a_id > > left outer join > > B b1_1_ > > on b1_.a_id=b1_1_.b_id > > WHERE > > b0_.c_...@p0; > > @p0 = 1 > > > Besides of using many-to-many element, is there another way to point > > out NH that it should look for a foreign key of the collection in the > > joined table? > > > Thank you.- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
