Hibernate Books

All times are UTC - 5 hours [ DST ]



Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Complex Mapping issue
PostPosted: Sat Jun 02, 2012 1:10 pm 
Newbie

Joined: Sat Jun 02, 2012 12:48 pm
Posts: 4
I wonder if it is possible to map the following:

- Suppose I have a table called "ServicesOrders" and "Users".
- ServicesOrders have 2 foreign keys, both from Users:

-- ServicesOrders
---- AnalystId (User)
---- TechnicianId (User)

So, in the User class I want to map the ServicesOrders table, ok? I could simple have two List<ServiceOrder> like follow:

Code:
public class User {...
    private List<ServiceOrder> analystServicesOrders;
    private List<ServiceOrder> technicianServicesOrders;
...}

In the mapping I would create two bags, one for each list:
Code:
<bag name="analystServicesOrders" table="ServicesOrders" lazy="true">
     <key column="AnalystId" not-null="false"/>
     <one-to-many class="ServiceOrder"/>
</bag>
<bag name="technicianServicesOrders" table="ServicesOrders" lazy="true">
     <key column="TechnicianId" not-null="false"/>
     <one-to-many class="ServiceOrder"/>
</bag>


Ok, but I don't want to do that. I want to have only one List<ServiceOrder> inside User class.
Is this possible somehow?


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

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.