-->
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: using a map to represent ternary associations
PostPosted: Wed Feb 01, 2006 7:23 pm 
Newbie

Joined: Tue Aug 09, 2005 3:03 pm
Posts: 14
I have four tables:
Roles the roles in the system
ACCESS_TYPE: read, write, etc
Property: resources in the system
I have a ternary associations represented by a fourth table:ROLE_MAPPING
I created three entities to represent the roel, property and access type. I wanted
to represent the ternary relation by using a map inside the entity Role. I am struggling with
that. Can someone please help me.

Code:
TABLE ROLE(ID INT,
ROLETYPE VARCHAR(20),
   );

TABLE ACCESS_TYPE(ID INT,
   NAME VARCHAR(10));

   
TABLE Property(ID INT
   NAME VARCHAR(30));

TABLE ROLE_MAPPING(ROLE_ID INT,
   Property_ID INT,
   PRIMARY KEY(ROLE_ID, Property_ID),
   ACCESS_TYPE_ID INT NOT NULL
   );
   
   @Table(name = "role")
   public class Role implements DataObject, Serializable  {

      @ManyToMany(targetEntity=Property.class)
      @MapKey(name="Property_ID")
      @JoinTable(
           table=@Table(name="ROLE_MAPPING"),
           joinColumns={@JoinColumn(name="ROLE_ID")},
           inverseJoinColumns={@JoinColumn(name="Property_ID")})
           }

thanks


Top
 Profile  
 
 Post subject: anyone?
PostPosted: Thu Feb 02, 2006 11:37 am 
Newbie

Joined: Tue Aug 09, 2005 3:03 pm
Posts: 14
Anyone please? I found examples of how to do this in the hbm but I am not able to find an example of using annotations to reflect this relation.

thanks!


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.