Hi,

I have a relationship between two tables which Im not sure sure is actually
possible to model with hibernate or not.

Here are my tables:


The app_user table (same as the app_user table in Appfuse 2, but i will omit
the irrelevant fields to the problem)
------------------
id
-1  (has a 'producer' role)
-2  (has a 'consumer' role)
-3  (has a 'consumer' role)    


The scheduleentry table
-----------------------
id    producer_id    consumer_id
-1    -1        -2
-2    -1        -3



So to summarize, i have 2 types of user - a provider and a customer.These
roles are in the role table as in the normal appfuse sense and are managed
with a link table, but this isnt important.

In the scheduleentry table, you can think of each row as a booking. A
scheduleentry is basically a booking between a provider with a consumer. Not
sure if this is relevant but the consumer field also has to be nullable.


To me this is a Many to many relationship, i.e. a provider can have many
scheduleentries associated with him, and conversely a consumer can have many
providers associated with him for different bookings.


Back in the java object model, I want the User obj to have a scheduleEntries
list which will:
    a) hold the list of scheduleentries for my customers if I am a producer
    b) hold the list of scheduleentries for my providers if I am a customer


I also have the following additional requirements:
If I am a 'producer' user and I get deleted, my associated scheduleentries
should get deleted aswell
If I am a 'consumer' user and I get deleted, my associated scheduleentries
should get deleted aswell
In the object model, if a scheduleentry gets deleted I want its reference in
the lists held by the producer user and the customer user to get deleted
also, so that they are not hanging on to stale lists.


So, what im really wondering is if the above relationship can in fact be
implemented at all, and if it is, then what are the annotations that I need
to
use in the object model.
If there is an easy way to model this I would also love to know.

Thanks
-- 
View this message in context: 
http://www.nabble.com/Can-Hibernate-map-this---tp14992855s2369p14992855.html
Sent from the AppFuse - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to