-->
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: Using Hibernate with interfaces and custom factory
PostPosted: Mon Nov 19, 2007 4:52 pm 
Beginner
Beginner

Joined: Mon Nov 19, 2007 4:40 pm
Posts: 46
Hibernate version: 3.2
Name and version of the database you are using: Oracle10g

I am sorry if this information out there, I am really having a hard time finding a solution. Does anyone know a good strategy for how I might support interfaces by providing a mechanism to load the appropriate implementations?

To be more specific, here is an overview of the objects I have and what I want to do. We have a set of interfaces which are loaded via a custom factory. The factory allows us to provide alternate implementations by overriding the defaults.

For example:
Code:
Person p = Person.Factory.createPerson();


The factory can be further simplified to:
Code:
Person p = Factory.createApiObject(Person.class);


This factory uses a property file to determine if the implementation is provided by the user... if not, it defaults to a provided impl.

The problem is that I would like to hook these interface classes into hibernate, but I am not sure how to do this because I need to use the factory to obtain the instance. I cannot simply supply the implementing class in Person.hbm.xml as I would lose my ability to allow the user of my library to provide their own implementation (to Person).

So, does anyone know how I might provide a custom classloader to do this?

Any help you all could provide me would be greatly appreciated.


Top
 Profile  
 
 Post subject: Update: Using Hibernate with interfaces and custom factory
PostPosted: Tue Nov 20, 2007 9:12 am 
Beginner
Beginner

Joined: Mon Nov 19, 2007 4:40 pm
Posts: 46
While continuing my research, I found this resource about implementing a Proxy Interceptor:

http://www.hibernate.org/339.html

Has anyone tried this and have any lessons learned that they would be willing to share?

I plan to try this out and post the results back here for anyone that might be interested.

Thanks in advance for your help...

Best Regards,

Paul


Top
 Profile  
 
 Post subject: Update: Using Hibernate with interfaces and custom factory
PostPosted: Tue Nov 20, 2007 3:19 pm 
Beginner
Beginner

Joined: Mon Nov 19, 2007 4:40 pm
Posts: 46
For the curious... I don't know if this is the best way to accomplish this, but my current tests indicate that Interceptors will work for this situation.

If anyone is looking to do this type of thing, I found a few resources by googling "hibernate interceptors" and the test packages in the hibernate source were invaluable.


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.