-->
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.  [ 5 posts ] 
Author Message
 Post subject: How can I map that structure?
PostPosted: Sun May 10, 2009 11:51 am 
Newbie

Joined: Sun May 10, 2009 11:30 am
Posts: 3
Hello,
I have the following Object model:

Code:
public class MyFirstClass
{
  private long id = -1;
  private MySecondClass class2 = null;
  private List<MySecondClass> class2List1 = null;
  private List<MySecondClass> class2List2 = null;
  private List<MySecondClass> class2List3 = null;
  private String content = null;
  private boolean property1 = true;
  private boolean property2 = false;
  private boolean property3 = false;

  (....)

and

Code:
public class MySecondClass
{
  private long id = -1;
  private String name = null;

  (....)

And the following tables model:

Code:
Table Table1
-------------
ID
TABLE2_ID
CONTENT

Code:
JOIN_TABLE_12
----------------
ID
TABLE1_ID
TABLE2_ID
TYPE
PROPERTY1
PROPERTY2
PROPERTY3

Code:
Table Table2
-------------
ID
NAME

In my mapping configuration for MyFirstClass, I know how to map simple fields, like id, class2 and content.
My mapping of MySecondClass is fine too.
I still cannot find how I can do the following:
1. Map each of the 3 list (class2List1, class2List2 and class2List3) using the field TYPE in the join table as a discriminant (so record with TYPE=1 will go in class2List1 and so on).
2. To map the 3 properties (property1, property2 and property3) to the corresponding fields in the join table.

If anybody could give me some help on that, and if possible some example, it would be greatly appreciated.
Thank you.
Regards,

&lt;


Top
 Profile  
 
 Post subject: Re: How can I map that structure?
PostPosted: Sun May 10, 2009 2:37 pm 
Beginner
Beginner

Joined: Sat Oct 18, 2008 10:25 am
Posts: 30
Hi,

I am not sure, if you can use a discriminator. As far as I know, discriminators are only used with inheritance. But here, I only see a n:m-relation. Or am I wrong? Do you need help with a mapping of this relation?


Top
 Profile  
 
 Post subject: Re: How can I map that structure?
PostPosted: Sun May 10, 2009 2:46 pm 
Newbie

Joined: Sun May 10, 2009 11:30 am
Posts: 3
Thank you for your support.
My problem here is not the m-n relation, but more how to discriminate 3 m-n relations that uses the same join table.
That's why I was asking about a way to use the TYPE table field as a discriminant.
My second problem is to be able to set the fields "property1", property2 and property3 to the values from the join table.
Thank you for your help.


Top
 Profile  
 
 Post subject: Re: How can I map that structure?
PostPosted: Sun May 10, 2009 3:28 pm 
Beginner
Beginner

Joined: Sat Oct 18, 2008 10:25 am
Posts: 30
Okay, I my interpretation of your message was wrong. I am German and my English is not the best ;)

Can you post your mapping?


Top
 Profile  
 
 Post subject: Re: How can I map that structure?
PostPosted: Mon May 11, 2009 10:55 pm 
Newbie

Joined: Sun May 10, 2009 11:30 am
Posts: 3
Well except easy mapping like basic fields I don't have any mapping at all as my problem here is that I do not know how to map my case.
I tried to find out in documentation but did not succeed.
I would be really happy if anybody can show me how to achieve that.

&lt;


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