-->
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.  [ 7 posts ] 
Author Message
 Post subject: Mapping two components of the same type
PostPosted: Tue Dec 09, 2003 10:57 am 
Newbie

Joined: Tue Dec 09, 2003 10:43 am
Posts: 7
I have to map two components of the same type, but hibernate maps them with the same name! Using Xdoclet, what happens is that I have two identical "component" elements inside my mapping document, so Hibernate throws

Hibernate lazy instantiation problem: Repeated column in mapping for class ... should be mapped with insert="false" update="false": propertyName
Here's the repeated element: (they only differs for the component name, of course, but the property are (and should be, I think) the same!!!)

<component name="normalizedDestination"
class="com.set.costamorena.server.business.data.GISNormalizedAddress"
>
<property
name="latitude"
type="java.lang.Long"
update="true"
insert="true"
column="latitude"
/>

<property
name="longitude"
type="java.lang.Long"
update="true"
insert="true"
column="longitude"
/>

</component>
Any ideas ?
Thanks
Renato


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 09, 2003 12:30 pm 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
The pb is that column should be different in your case. I don't think this is doable with xdoclet right now.

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 5:34 am 
Newbie

Joined: Tue Dec 09, 2003 10:43 am
Posts: 7
should I write somethibg like:

<component name="normalizedDestination" class="...">
<property name="latitude" column="destinationLatitude" />
<property name="longitude" column="destinationLongitude"/>
</component>

<component name="normalizedOrigin" class="...">
<property name="latitude" column="originLatitude" />
<property name="longitude" column="originLongitude"/>
</component>

that's right ?? But as you say it seems to be impossible using Xdoclet!! What then ?? I started using Xdoclet and I fount it a very nice of describing OR mappings...
Maybe I should use margeFiles, but I made some tries without results!! ant seem to ignore whatever i put in the mergefile... some hints about this ??
Thanks a lot


Top
 Profile  
 
 Post subject:
PostPosted: Fri Dec 12, 2003 6:16 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
You will need to use mergefiles for this - remember that you need to put the mergefiles in a directory structure under the mergedir, according to your class package. So if you class is de.test.BlaBla and your mergedir ist /mergedir, you will need a directory structure like this:
/mergedir/de/test/<BlaBla-Mergexile>


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2003 5:17 am 
Newbie

Joined: Tue Dec 09, 2003 10:43 am
Posts: 7
Thank you very much! Your hint was very useful. I only have one more question: my components definition is inside a joined-subclass element:

<class A>
...
<joined-subclass ...B>
<component>

.........
</component>
<component>

.........
</component>
</joined-subclass>
</class>

So I think to proceed this way:
eliminate the xdoclet tag for one of the components;
put the xml component definition in a merge file hibernate-properties-A.xml
but this (of course) puts the definition of the component inside the A mapping!! Putting the definition in hibernate-properties-B.xml has no result!!


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2003 5:35 am 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
xdoclet usually places a comment in the xml files describing how to call your mergefiles to generate output at a specific place. If there is no such comment in the generated file where you want to have your component mapping, you will have to use uglier methods like putting your whole subclass mapping in the mergefile ...


Top
 Profile  
 
 Post subject:
PostPosted: Tue Dec 16, 2003 6:03 am 
Newbie

Joined: Tue Dec 09, 2003 10:43 am
Posts: 7
In fact there is a comment, but only at class definition level, so I think as you suggest to put the whole subclass def in the merge file, even if this doesn't like me too much !!


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