-->
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: Does hibernate.component prefix attribute work?
PostPosted: Tue Nov 30, 2004 10:57 am 
Regular
Regular

Joined: Sun Nov 07, 2004 3:39 pm
Posts: 77
I have failed so far to get the prefix attribute of the @hibernate.component tag to make any difference whatsoever and I was wondering whether anyone else was using it. My situation is that I have a Location class with two Latitude fields, differentiated by the following prefixes:

* @hibernate.component prefix="lat1" class="testing.om.geography.Latitude"

* @hibernate.component prefix="lat2" class="testing.om.geography.Latitude"

When the mapping files are generated, the prefix is not used and instead the mapping file ends up with these two tags:


<component
name="latitude1"
class="testing.om.geography.Latitude">
<property
name="decimalValue"
type="double"
update="true"
insert="true"
access="property"
column="value" />
</component>


<component
name="latitude2"
class="testing.om.geography.Latitude">
<property
name="decimalValue"
type="double"
update="true"
insert="true"
access="property"
column="value" />
</component>

The column name used is the one set in the tag in the Latitude class:

/**
* @hibernate.property column="value" type="double"
*/
public double getDecimalValue(){
return decimalValue;
}

Unsurprisingly the second component tag effectively overwrites the first, leaving a single 'value' column. The prefix is completely ignored.

I know prefix is a reasonably recent addition, and I was wondering whether it was working yet. I'm using the 1.2.2 version of the XDoclet module, and Hibernate 2.1.7c.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 30, 2004 11:15 am 
Regular
Regular

Joined: Sun Nov 07, 2004 3:39 pm
Posts: 77
OK, I've got this one sorted now. For the benefit of others who are stumped by this, I hadn't fully registered the following from the docs:

'Properties that are included which have a @hibernate.property column-name="xxx" attribute will not be prefixed. If you want to shorten a property column-name and prefix it for the component, use @hibernate.column name="xxx" on the property.'

When I changed my tag in the Latitude class to this:

/**
* @hibernate.property type="double"
* @hibernate.column name="value"
*/
public double getDecimalValue(){
return decimalValue;
}

(i.e., NOT specifying the column as an attribute of the property tag, but separately) it all worked fine and I ended up with nice 'lat1value' and 'lat2value' columns.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 04, 2005 4:59 pm 
Newbie

Joined: Wed Sep 08, 2004 4:16 am
Posts: 5
Thanks a lot!


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.