When initializing a collection NH doesn't consider the case that the
foreign key of the collection can be joined from another table.
NH assumes that the FK belongs to the table to which entity from the
collection has been mapped.

here is my test DB schema

create table A
(
a_id int not null identity primary key,
a_field_a char(20) not null,
a_type char(1) not null
)

create table C
(
c_id int not null identity primary key,
c_field_c char(20) not null
)

create table B
(
b_id int not null primary key references A(a_id),
b_field_b char(20) not null,
c_id int not null references C(c_id)
)

and here is SQL generated by NH when it tries to initialize
collection:

 /* load one-to-many NHTest.Model.C.B */ SELECT
     b0_.c_id as c4_1_,
     b0_.a_id as a1_1_,
     b0_.a_id as a1_3_0_,
     b0_.a_field_a as a3_3_0_,
     b0_1_.b_field_b as b2_4_0_,
     b0_1_.c_id as c3_4_0_
 FROM
     A b0_
 inner join
     B b0_1_
         on b0_.a_id=b0_1_.b_id
 WHERE
     b0_.c_...@p0;

and an error thrown by NH : "Invalid column name 'c_id'.\r\nInvalid
column name 'c_id'."

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