Maybe this is the wrong way to do it, but I have my factories making the hibernate calls instead of hibernate calling the factory.
I wrote a factory for each class which all implemented a common interface. Then I wrote a builder for the factories, so my code looks like:
Factory f = FactoryBuilder.build(new CustomObject());
The factory builder builds the correct factory based on the object passed to it. Then in the factory I have simple methods like getObject, getObjects, etc. Each of these methods builds the appropriate hql for the object you are trying to get based upon what it was constructed with... so it should be easy to do your IOC stuff along with that.
I did it this way since it is easy to unplug hibernate and plug in jdbc or toplink and that was a requirement for development. Not sure if this is what you were looking for, but that's how I used custom factories with Hibernate.
|