-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: [v. 1.0.3] Multiple PrimaryKey with PrimaryForeignKey
PostPosted: Sat Jan 13, 2007 1:31 pm 
Newbie

Joined: Sat Jan 13, 2007 12:55 pm
Posts: 1
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


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.