-->
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: How to store multiple properties in a set?
PostPosted: Mon Aug 28, 2006 8:22 am 
Newbie

Joined: Wed Jul 13, 2005 9:04 am
Posts: 3
Hibernate version:
3.0
Mapping documents:

I have two classes: Activity and Resource

At the moment these two have a many-to-many relationship, each Activity has a set of Resources and each Resource has a set of Activities:

Code:
    <class name="data.Resource" table="resource" >
        <id name="id" column="resource_id">
            <generator class="increment"/>
        </id>
        <set name="activities" table="ResourceActivity" order-by="activity_id" lazy="true" cascade="save-update">
            <key column="resource_id"/>
            <many-to-many column="activity_id" class="data.Activity"/>
        </set>
    </class>


And the same again for Activity, but with a set of resources.

I now want to record the strength of the relationship, such as weak or strong. I have created a new class called Relationship which has three properties, an activity, resource and strength. My resources' set of activities is now a set of relationships as is my activities' set of resources. How do I define this in my hbm.xml file though as I cannot do as follows?

Code:
   <class name="data.Activity">
        <id name="id" column="activity_id">
            <generator class="increment"/>
        </id>
        <set name="resources" table="ResourceActivity" order-by="resource_id" lazy="true" cascade="save-update">
            <key column="activity_id"/>
            <many-to-one name="strength"/>   !!! not allowed !!!
            <many-to-many column="resource_id" class="data.Resource"/>
        </set>
    </class>


I would like my rel table to look along the lines of:
Code:
| activity_id | resource_id | strength |
| 5           | 6          | 1         |
| 7           | 8          | 2         |

... etc.

Name and version of the database you are using:
Oracle 10


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.