-->
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.  [ 8 posts ] 
Author Message
 Post subject: Need help for mapping
PostPosted: Fri May 26, 2006 10:09 am 
Newbie

Joined: Fri May 26, 2006 9:56 am
Posts: 4
Hello!

I have a general question about component-mapping. I would like to map the following class-structure:

Class1 with 2 members:

- member1
- member2

Both member have a "complex" class-structure, so I would like to map directly (with a key) to the corresponding tables for the classes. Maybe you can call it a 1:2 - mapping. First I tried the <component>-tag, but I think it is not useful for me. So far I understand the one-to-many - mappings described in the documentation, only works with lists/sets ...

I believe the solution is very easy, but I dont get it!

Thanks for help!

temp


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 2:52 am 
Newbie

Joined: Fri May 26, 2006 9:56 am
Posts: 4
Hello again! :-)

Because there is no answer yet:
Is my question not precise enough or to trivial ? :-)

Greetings


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 3:02 am 
Senior
Senior

Joined: Thu Aug 25, 2005 3:35 am
Posts: 160
it is too vague for me to answer.
It seems like a component mapping indeed. Why is that not useful?


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 3:22 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Or two many-to-one's. Please post your classes and the mapping files you have so far and what doesn't work.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 3:29 am 
Newbie

Joined: Fri May 26, 2006 9:56 am
Posts: 4
Ok I will try to describe my problem more in detail:

I have a class "object", which has two attributes:

Code:
public class object
{

private Attribut attrib1;
private Attribut attrib2;

...
}


A "normal" component-mapping would look like this:
Code:
<class name="object" table="object">

...
      
<component name="attrib1" class="Attribut">
<property name="xyz"/>
...
</component>


My problem is, that this attributes are polymorph "complex" classes, which should have a seperate table in the database! They havenĀ“t not properties like normal string etc.
I would like to link the component by a key of the attribute-table, if this is possible!
Are many-to-ones relations only useful for lists,sets,etc. ?!


Problem 2:
Is it possible to map recursive class-structures? Maybe a class object, which itself has a component object?


Greetings


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 3:47 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You are confusing many-to-one's and one-to-many's. Many-to-one's should work fine in your case.


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 5:18 am 
Newbie

Joined: Fri May 26, 2006 9:56 am
Posts: 4
Thanks! It seems, that this is the solution!

Only one short question:
Is cascading not possible with this approach? When I tried to save the "object" , the attributes were in transient state!


Top
 Profile  
 
 Post subject:
PostPosted: Tue May 30, 2006 7:15 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, cascading is possible, use <many-to-one cascade="save-update" />.


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