-->
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.  [ 3 posts ] 
Author Message
 Post subject: Mapping a List to many tables
PostPosted: Thu Jun 21, 2012 4:30 am 
Newbie

Joined: Thu Jun 21, 2012 4:00 am
Posts: 2
Hi I need help about this scenario:

I've a bean User that have a List/Set of initiatives.
Initiative is a class that have 4 properties.
I have InitiativeA extends Initiative and InitiativeB extends Initiative.

Now, I need to populate the initiatives List of User but:
- InitiativeA and InitiativeB must not share the ID with Initiative, it will be indipendent (so discriminator can't help me).
- Initiative is only topologic table, InitiativeA and InitiativeB have foreign key to User.

Tables:
Code:
User:
------
ID
NAME

Initiative:
---------
ID
DESCRIPTION

InitiativeA:
-----------
ID
USER_ID
ADHESION (true/false)

InitiativeB:
-----------
ID
USER_ID
ADHESION (true/false)


Beans:

Code:
public class User{
    private Integer id;
    private String name;
    private Set<Initiative> initiatives;
}

public class Initiative{
    private Integer id;
    private String description;
}

public class InitiativeA extends Initiative{
    private Integer id;
    private User user;
    private Boolean adhesion;
}

public class InitiativeB extends Initiative{
    private Integer id;
    private User user;
    private Boolean adhesion;
}


How can I map this into hbm files?

thanks a lot.


Top
 Profile  
 
 Post subject: Re: Mapping a List to many tables
PostPosted: Sat Jun 23, 2012 9:36 pm 
Beginner
Beginner

Joined: Tue Oct 30, 2007 7:57 am
Posts: 47
The way you want to use InitiativeA and InitiativeB as subclasses of Initiative, forces you to use hibernate inheritance, so I am afraid there is no other solution but to share a common id.


Top
 Profile  
 
 Post subject: Re: Mapping a List to many tables
PostPosted: Mon Jun 25, 2012 4:53 am 
Newbie

Joined: Thu Jun 21, 2012 4:00 am
Posts: 2
Rober2D2 wrote:
The way you want to use InitiativeA and InitiativeB as subclasses of Initiative, forces you to use hibernate inheritance, so I am afraid there is no other solution but to share a common id.


You think there is not solution to do this?


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