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
public Class Client
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?
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.