-->
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.  [ 4 posts ] 
Author Message
 Post subject: Determine BiDirectional Property Name through Metadata
PostPosted: Fri Aug 05, 2005 2:33 pm 
Newbie

Joined: Fri Jul 22, 2005 9:14 pm
Posts: 10
I would like to determine the property name of my biDirectional relationship through the Metadata. I've tried using "property-ref" and discovered that "property-ref" is for something else.

For instance...

A has a set of B stored at a property name of "bSet"
B has an instance of A stored at a property name of "a"

I would like to obtain the property name "a" from the property "bSet" meta data and visa versa. Is this possible or do I have define this meta data is some other format. I would think you should be able to do this.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 2:39 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Hibernate does not *know* the name of the inverse property (it is never specified in the mapping document).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 2:47 pm 
Newbie

Joined: Fri Jul 22, 2005 9:14 pm
Posts: 10
To give some context as to why I've requested this or why I believe it would be useful is because I attempting to build a dynamic persister based around my domain model in an effort to reduce code. To do this I am going to need to determine if a relationship has an inverse (already know how to do that) and the name of the inverse relationship (obviously cannot do). Do you think a feature such as this would make it into future releases?

Thanks for your quick response

Tim


Top
 Profile  
 
 Post subject:
PostPosted: Fri Aug 05, 2005 7:31 pm 
Beginner
Beginner

Joined: Mon Nov 29, 2004 11:51 am
Posts: 31
Hi Triley,
I had the same need and have spent a little bit of time on it. I don't have an easy answer for you but possibly a simple workaround. I first tried the metadata route as it seems the most logical. I was going to attempt to do this by getting the collection 'key' column to match with the referenced property column. That wouldn't work in all cases, but seemed reasonable for mine. However, there's something funky with the metadata api. I just couldn't do something as simple as get the key value for the collection mapping. I could get a reference to my collection mapping, but not much else... most of the properties (like getKey()) always came back null.
So if you've done better there, please let me know... I'm really curious what's up.

Anyway, my little workaround has been to simply but my own meta tag under the collection with the value being the name of the property in the referenced class. For example...
<meta attribute="inverse-property">parent</meta>

Then, I can access this at runtime and all is good. If you need more details on how to do that, let me know.

Good luck.


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