-->
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: Map association key in map value (map-key-many-to-many)
PostPosted: Wed Oct 12, 2005 3:20 pm 
Newbie

Joined: Wed Oct 12, 2005 2:34 pm
Posts: 3
My Subject class has a map collection of forms, where the key to each form is a Study object. Unfortunately, I haven't found a way to use the Map mapping for this association since the study_id key is in the form's table.

The schema looks like:
Code:
create table SUBJECT_FORM (
   SUBJECT_ID INT8 not null,
   FORM_ID INT8 not null,
   primary key (SUBJECT_ID, FORM_ID)
);

create table FORM (
   FORM_ID INT8 not null,
   VERSION VARCHAR(30) not null,
   STUDY_ID INT8,
   primary key (FORM_ID)
);


The hibernate mapping I considered for my Subject class:
Code:
<map name="completedForms"
            table="SUBJECT_FORM"
            cascade="none">

            <key column="SUBJECT_ID" />

            <index-many-to-many
                class="Study"
                column="STUDY_ID"
            />

            <many-to-many
                class="Form"
                column="FORM_ID"
             />

        </map>


But to get this I would need to add the study_id in the SUBJECT_FORM relationship table to make it a ternary relationship in one table. The problem is that, each Form has a study, and a Subject has a collection of forms, so I don't want to denormalize and repeat the study_id in the relationship SUBJECT_FORM table and the FORM table.

Is there a way to specify a map key for a many-many association that is in the joined table, not the relationship table?

Any help would be GREATLY appreciated :)

Thanks,
Adam


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.