This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Many to Many situation for JSF?

 
David Pantale
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Beginner question here. I think this is a Hibernate question but possibly it is for JSF. Anyway, I'm using JSF and Hibernate and I have 2 classes -

public Class Appointment
DateTime date;
Client client;


public Class Client
String name;
List<Appointments> appointments;

As above, each client can have many appointments but an Appointment can have only one client - a one to many relationship.
The problem is that when creating an appointment (which has only one client) I want the user to be able to select the client from a dropdown list of clients.
One way I can see doing that is if I change the above to a Many to Many relationship so that the when I am creating a new appointment I use the list of clients to populate the drop down list.

Is there a standard way of doing this?

Possibly I should have a getAllClients method in my AppointsBusinessObject and use that to populate the dropdown list?

Thanks, Dave
 
Bill Gorder
Bartender
Posts: 1682
7
Android IntelliJ IDE Linux Mac OS X Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your Entities should be mapped in terms of the domain. It does not sound to me like there is a relationship between an appointment and a list of clients. Perhaps you need to introduce a new Entity like Facility or Associate which contains a list of clients. Since relationships can be bi-directional you could walk up that tree. From the appointment you could get the client and from the client you could get the facility/associate and from the facility/associate you could get a list of clients.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic