-->
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.  [ 2 posts ] 
Author Message
 Post subject: many to many mapping strategy
PostPosted: Fri May 20, 2005 4:56 am 
Newbie

Joined: Fri May 20, 2005 4:46 am
Posts: 2
Hi
I'm new Hibernate 3.0.3 user.

I have tables similar to:

User:
user_id|name

Group:
group_id|name

Users-Groups:
user_group_id|group_id|user_id

What is the best strategy for mapping relations like above one ?


mttu


Top
 Profile  
 
 Post subject:
PostPosted: Fri May 20, 2005 5:26 am 
Beginner
Beginner

Joined: Mon Mar 07, 2005 12:02 pm
Posts: 39
Dunno if this will work, it works for me:

<hibernate-mapping>
<class
name="User"
table="User"
dynamic-update="false"
dynamic-insert="false">

<id
name="user_id"
column="user_id"
type="int"
unsaved-value="null">
<generator class="assigned"/>
</id>

<property
name="name"
type="java.lang.String"
update="true"
insert="true"
access="property"
column="name"/>

<bag
name="groups"
table="groups"
lazy="false"
inverse="false"
cascade="none"
>

<key
column="user_id"
>
</key>

<many-to-many
class="za.co.easypay.easycredit.Group"
column="group_id"
outer-join="auto"
/>

</bag>
</class>


</hibernate-mapping>


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

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.