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: many-to-many relation and additional PK?
PostPosted: Thu Oct 16, 2008 8:47 am 
Newbie

Joined: Thu Dec 13, 2007 3:13 pm
Posts: 9
hi there,

i have several entities persisted with nhibernate. between some of them there are many-to-many relations with a bag, i.e. that the table looks like

Code:
table equipment_2_connection
     vehicleID, int, not null
     equipmentconnectionID, int, not null


where equipmentconnectionID is a foreign key to the EquipmentConnection's table ID and vehicleID is a foreign key to the Vehicle's ID column.

now i want to synchronize this data with microsoft sync framework. everything works fine, exception the many-to-many relation tables as i cannot enable change tracking (sql 2008) on them due to the fact that they do not contain a PK.
as i want the schema to be generated automatically from within nhibernate, i wonder if there is a way to tell nhibernate in my configuration to add a simple PK ID column...

my config for this relation looks something like this:

Code:
<bag name="Equipments" table="Equipment_2_Connection" cascade="save-update" lazy="false" >
      <key column="VehicleID"/>
      <many-to-many column="EquipmentConnectionID"
                    class="mynamespace.EquipmentConnection, mylibrary"/>
</bag>




EDIT: i'm sorry. i just answered my own question.
the solution was to substitute <bag> with an <idbag>. that's it. no magic, no foo, just a few lines of config.
thank's though ^^[/b]


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.