-->
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.  [ 5 posts ] 
Author Message
 Post subject: Resolve qualified from unqualified entity name?
PostPosted: Mon Mar 19, 2007 10:12 pm 
Newbie

Joined: Sun Jul 31, 2005 7:53 pm
Posts: 17
Dear All,

For my project, I need to determine the fully-qualified name of a class in my model (eg. com.foo.Bar) purely from its un-qualified name (eg. Bar).

Clearly, HQL does this all the time because you can write...

Code:
select from Bar


...and it knows that maps to com.foo.Bar. And, indeed this information is all there in the .hbm files.

So my question is, how can I extract it myself? I've been digging around from Session->SessionFactory and looking at the ClassMetadata, but everything in there is already fully-qualified?

So how does the unqualified->qualified mapping in HQL work?

Regards,

Richard.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 8:10 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
Configuration.getImports() seems to give a Map that has the SimpleName as a key and a fully qualified name as the value

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 20, 2007 6:12 pm 
Newbie

Joined: Sun Jul 31, 2005 7:53 pm
Posts: 17
Awesome - thanks scesbron!

Is there an 'official' way to navigate from the Session back to the Configuration (possibly via SessionFactory), or should I lug my Configuration around with me?


Top
 Profile  
 
 Post subject:
PostPosted: Wed Mar 21, 2007 3:50 am 
Expert
Expert

Joined: Thu Sep 04, 2003 8:23 am
Posts: 368
No

The SessionFactory does not hold a reference on the configuration object. If you want to use the configuration object you have to hold it somewhere in your app.
Although SessionFactoryImplementor has a method getImportedClassName that does the same, so you can use your SessionFactory for that but you will have to cast it to SessionFactoryImplementor to do that (it is not public on the SessionFactory interface)

_________________
Seb
(Please don't forget to give credits if you found this answer useful :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 22, 2007 12:51 am 
Newbie

Joined: Sun Jul 31, 2005 7:53 pm
Posts: 17
You are an absolute legend.


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