Hi all,
I'm a newbie of NHibermate 1.0.3 and I've already successfully mapped some not too simple databases, but now I have a big (for me) problem.
I hope you may help me.
I've a following database structure:
Code:
CREATE TABLE [dbo].[ATC1](
[ATC1] [nchar](1) NOT NULL,
CONSTRAINT [PK_ATC1_1] PRIMARY KEY CLUSTERED
(
[ATC1] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[ATC2](
[ATC2] [nchar](2) NOT NULL,
[ATC1] [nchar](1) NOT NULL,
CONSTRAINT [PK_ATC2_1] PRIMARY KEY CLUSTERED
(
[ATC2] ASC,
[ATC1] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
CREATE TABLE [dbo].[ATC3](
[ATC3] [nchar](1) NOT NULL,
[ATC1] [nchar](1) NOT NULL,
[ATC2] [nchar](2) NOT NULL,
CONSTRAINT [PK_ATC3_1] PRIMARY KEY CLUSTERED
(
[ATC3] ASC,
[ATC1] ASC,
[ATC2] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
ALTER TABLE [dbo].[ATC2]
WITH CHECK ADD CONSTRAINT [FK_ATC2_ATC1] FOREIGN KEY([ATC1])
REFERENCES [dbo].[ATC1] ([ATC1])
ALTER TABLE [dbo].[ATC3]
WITH CHECK ADD CONSTRAINT [FK_ATC3_ATC2] FOREIGN KEY([ATC2], [ATC1])
REFERENCES [dbo].[ATC2] ([ATC2], [ATC1])
I've mapped the ATC1 and ATC2 tables in this way:
Code:
<class name="Atc1" table="ATC1">
<id column="ATC1" name="_Atc1" type="String">
<generator class="assigned"/>
</id>
<bag name="_Atc2List" inverse="true" lazy="true" >
<key column="ATC1" />
<one-to-many class="Atc2" />
</bag>
</class>
...
<class name="Atc2" table="ATC2">
<composite-id>
<key-many-to-one name="_Atc1" column="ATC1" class="Atc1"/>
<key-property name="_Atc2" column="ATC2"/>
</composite-id>
<bag name="_Atc3List" inverse="true" lazy="true" >
<key ***I really don't know***/>
<one-to-many class="Atc3" />
</bag>
</class>
...
<class name="Atc3" table="ATC3">
<composite-id>
<key-many-to-one ***I really don't know***/>
<key-property name="_Atc3" column="ATC3"/>
</composite-id>
</class>
Someone could help me with the Multiple PrimaryForeignKey mapping?
What I could write instead of ***I really don't know*** part of the code?
Thank you very much.
Makbek