-->
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.  [ 2 posts ] 
Author Message
 Post subject: Using Hibernate to instantiate objects
PostPosted: Thu Jul 21, 2005 3:59 pm 
Senior
Senior

Joined: Thu May 12, 2005 11:40 pm
Posts: 125
Location: Canada
Hibernate knows the implementations of my interfaces. I know this because I can issue a "from Person" and get instances of PersonImpl back. Leveraging this functionality would be useful to me, because I want to write something like this:

Code:
class EntityFactory
{
    static <E extends Entity> E newInstance(Class<E> interfaceClass) { ... }
}


Instead of writing my own code to do the resolution and reflective instantiation, I'd like to leverage Hibernate to do it for me. However, I can't seem to pinpoint the code that actually does this. I know about ClassMetadata.instantiate, but SessionFactory.getClassMetadata returns null if I pass it anything other than the actual implementation.

What classes/packages should I be looking in?


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 18, 2005 11:46 am 
Senior
Senior

Joined: Thu May 12, 2005 11:40 pm
Posts: 125
Location: Canada
I stumbled across the answer to this by accident today. The key method is SessionFactoryImpl.getImplementors(). Hopefully that can be useful to someone else.


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