-->
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: Hot to get the referenced Class Name
PostPosted: Wed Apr 13, 2005 10:42 am 
Newbie

Joined: Tue Apr 05, 2005 5:39 am
Posts: 6
Location: Stuttgart, Germany
Hi,
I am attaching below an section from xyz.hbm.xml document



<set name="subGroups"
cascade="all-delete-orphan"
inverse="true"
lazy="true"
batch-size="5"
sort="natural">
<key column="groupnode_id"></key>

<one-to-many class="com.bosch.mds.types.hierarchy.SubGroupNode"/>

</set>


I need to know, how can programatically retrieve the class represented by the <one-to-many> tag for the attribute value <set name="subGroup"> from the above section. I have got the PersistentClass from the Hibernate Configuration.

Please help !!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 9:07 am 
Regular
Regular

Joined: Tue Nov 29, 2005 12:31 pm
Posts: 75
Hi,

Did you find out what was the answer ? If so please post it here.

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 11:06 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 3:00 pm
Posts: 1816
Location: Austin, TX
Code:
String collectionRole = persistentClass.getEntityName();
Collection subGroupMapping = configuration.getCollectionMapping( collectionRole );
OneToMany subGroupElements = ( OneToMany ) subGroupMapping.getElement();
String associatedEntity = subGroupElements.getReferencedEntityName();
// or :
// PersistentClass oneToManyRef = subGroupElements.getAssociatedClass();
// String associatedEntity = oneToManyRef.getEntityName();
// Class associatedClass = oneToManyRef.getMappedClass();

Beware, though, that you need to make sure the associations are fully resolved *before* making these calls.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 11, 2006 11:56 am 
Regular
Regular

Joined: Tue Nov 29, 2005 12:31 pm
Posts: 75
Steve,

One remark regarding your code, shoud be

String collectionRole = persistentClass.getEntityName() + "." + attribute;

Anyway my problem was this one http://forum.hibernate.org/viewtopic.ph ... highlight= (please see the topic and my post).

Can you please have a quick look on it ?

P.S. How can I rate your answer ? (or only the thread starter can ?)

Thanks 4 your time.


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.