-->
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: Hibernate annotations when using collection of components
PostPosted: Mon May 08, 2006 11:28 am 
Newbie

Joined: Fri Jan 20, 2006 2:19 am
Posts: 4
Hi all,

I'm using hibernate 3.2.0.CR1 and annotations 3.1 beta 9. My problem is following:

I have a unidirectional many-to-many association between customers and roles (Customer class should have a method called getRoles()). The mapping table however also has an extra attribute expiryDate, that will tell when the specific role for the customer will expire (see the table definitions below). How can I do this by using annotations. I think the CollectionOfElements is the way to go, but have not found any examples for my specific problem.

I also think that I will need three different classes one for customer, one for the role and one for the customer_role mapping. Am I right or is there a way to do this without having a class for the customer_role?

Code:

tbl_customer
---------------
id
other fields                             
                         

tbl_customer_role
---------------------
tbl_customer_id
tbl_role_id
expiry_date


tbl_role
--------------
id
other fields


Thanks,
Marika


Top
 Profile  
 
 Post subject: One solution
PostPosted: Thu May 11, 2006 2:27 am 
Newbie

Joined: Fri Jan 20, 2006 2:19 am
Posts: 4
I found one solution:

http://java-aap.blogspot.com/2006/04/hi ... imary.html


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.