-->
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.  [ 4 posts ] 
Author Message
 Post subject: Design pattern help
PostPosted: Tue Jun 26, 2007 7:02 am 
Beginner
Beginner

Joined: Fri Apr 27, 2007 11:50 am
Posts: 23
Hi,

I've come across a problem with regards to a certain design pattern.

I have a User object and a PageSet object. A PageSet object has a list of User objects associated with it, but as part of that list, the User has a Color property (ie the Color property only exists for the PageSet User combination)

Could someone offer any advice on how this should be designed?

Would i need a PageSetUser object that has a PageSet, User and Color property, or would i subclass user somehow?

I've had this problem before, but never know how to resolve it.

Any help aprechiated.

Many thanks

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 1:50 pm 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You could probably use a <map> in the PageSet and map the User to its color. Or use a PageSetUser object, mapping as a <composite-element> of a list. Subclassing is definitely not the answer.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 26, 2007 3:26 pm 
Beginner
Beginner

Joined: Fri Apr 27, 2007 11:50 am
Posts: 23
The PageSetUser was the only way i knew to do it myself, but it never seems right to me for some reason.

Thanks for the info on <composite-element>, i'm looking into it now.

Many thanks

Matt


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 28, 2007 7:39 pm 
Expert
Expert

Joined: Fri Oct 28, 2005 5:38 pm
Posts: 390
Location: Cedarburg, WI
We have this kind of situation all the time, and we explicit association entities (like the PageSetUser example) across the board for them. They are then mapped as one-to-manys. It can be a little cumbersome (e.g. you end up with PageSet.PageSetUser.User to get at the user) and might seem unnecessary until you realize that almost any kind of association has properties that only apply to the association and not to either entity. A classic example is the role a person plays in a project or department. that role belongs to the association between the person and the project or department, and not to the person itself. Also, it's not uncommon to want to know the date when the the association was established, or if the association is "active", etc.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.