-->
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: question many-to-many mapping with different column names
PostPosted: Sun Jan 29, 2006 3:37 pm 
Newbie

Joined: Sun Jan 29, 2006 3:27 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version:
nhibernate 1.0.2.0

I want to map 2 tables (many to many):
CREATE TABLE tUser (
user_id [int] IDENTITY (1, 1) NOT NULL ,
user_name [nvarchar] (50));

CREATE TABLE tGroup (
group_id [int] IDENTITY (1, 1) NOT NULL ,
group_name [nvarchar] (50));

CREATE TABLE tGroup_User (
group_user_id [int] IDENTITY (1, 1) NOT NULL ,
user_key int references tUser(user_id)
group_key int references tGroup(group_id));

so, my problems is, that the name of the primary key in tuser is different
from the foreign key in tGroup_User.


So, how do i map the different names in my idbag?,
do there exists eg. a alias tag?

<class name="Business.Group, nibernate_test" table="tGroup">
<id name="Group_id" column="group_id" access="nosetter.camelcase" unsaved-value="0">
<generator class="identity" />
</id>
<property name="Group_name" column="group_name" />
<property name="Group_comment" column="group_comment" />
<property name="Domain_key" column="domain_key" />
<property name="Site_key" column="site_key" />
<property name="Ou_key" column="ou_key" />


<idbag name="Users" table="tGroup_User" lazy="false">
<collection-id column="group_user_id" type="long">
<generator class="identity"/>
</collection-id>
<key column="group_id"/>
<many-to-many column="user_id" class="User" outer-join="true"/>
</idbag>

</class>


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.