-->
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.  [ 3 posts ] 
Author Message
 Post subject: help. a *not* typical many-to-many relationship.
PostPosted: Sun Jan 30, 2005 10:07 am 
Newbie

Joined: Sun Jan 30, 2005 9:57 am
Posts: 2
i saw a lot of example on the web regarding to do a typical m-m relationship. but i've a problem.

assume i have 3 tables.

user -> uid, name

course -> cid, name

subscription -> uid, cid, status

______

if i'd use the normal

<set name="courses" table="subscription" inverse="true">
<key column="uid" />
<many-to-many column="cid"
class="xxx.Course" />
</set>

and

<set name="users" table="subscription">
<key column="cid" />
<many-to-many column="uid"
class="xxx.User" />
</set>

i can't retrieve the status field in the subscription table.

is there any solution?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 30, 2005 11:40 am 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
check composite element in the reference guide, hibernate in action, i think there are many examples in the forum too.

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Sun Jan 30, 2005 1:01 pm 
Newbie

Joined: Sun Jan 30, 2005 9:57 am
Posts: 2
yes, i guess i did solve this one. but i don't know i solve in a good way or not.

__


<class name="net.insyn.hub.domain.ex.Subscription" table="usercourse" >
<composite-id>
<key-property name="status" column="status" />
<key-many-to-one name="users" class="net.insynchro.phub.domain.ex.User" column="userid"/>
<key-many-to-one name="courses" class="net.insynchro.phub.domain.ex.Course" column="courseid"/>
</composite-id>
</class>

__


this is the hashcode func in the subscription class

__

public int hashCode() {
int result;
result = Integer.parseInt(user.getUserId());
result = 29 * result + Integer.parseInt(package.getId());
return result;
}

__


stdout -> from object in class net.insynchro.phub.domain.ex.Subscription

__

is that the only way to access the status field? is this way of doing elegant? is there any other better way to do it?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 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.