-->
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 Mapping Help Needed
PostPosted: Wed Nov 29, 2006 2:41 pm 
Newbie

Joined: Thu May 25, 2006 7:16 pm
Posts: 2
I am having trouble figuring out how to accomplish the following JOIN:

I have three tables, Device, DeviceFeature and Feature.

Device represents a physical hardware device. Feature contains features that a device may have. DeviceFeature contains the values for these features for each Device.

Example:

Code:
Device
===========
DeviceId (PK)
Name

Feature
===========
FeatureId (PK)
Name

DeviceFeature
===========
DeviceFeatureId (PK)
DeviceId (FK)
FeatureId (FK)
Value


So, an example device would be:

Code:
DeviceId Name
======== ==========
1        Server


and an example feature would be:

Code:
FeatureId  Name
=========  ==========
1          IPAddress


so, if I wanted to assign an IP address to device 1 (Server) I would have the following DeviceFeature record

Code:
DeviceFeatureId DeviceId FeatureId Value
=============== ======== ========= ========
1               1        1         192.168.0.1


The problem I am having is coming up with an efficient mapping in Hiberate. Ideally I want a Device to have a map of Features, with the key being Feature.Name and the value being DeviceFeature.Value (and have this map cascade to inserts, updates and deletes).

So far I have a Device mapping to a set of DeviceFeatures and each DeviceFeature maps to a Feature (this is a long painful traversal)

Any help you can provide would be appreciated.

Thanks,
Mark


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.