I'm interested in changing the object creation behavior of the elements in Hibernate: how they're created and where they're created from.
e.g. If I ask for:
select foo from com.paraware.Foo as foo
and foo is related to bar and baz and lazy init is false, then I suspect hibernate does this:
Object foo = Class.forName.newInstance("com.paraware.Foo");
// figure out the properties of foo are and then:
Object bar = Class.forName.newInstance("com.paraware.Bar");
// find the properties of bar and
Object baz = Class.forName.newInstance("com.paraware.Baz");
Obviously hibernate uses cglib and reflection to do this sort of thing (i.e. it's not hardcoded as in my example), but I am curious how it navigates the graph and where object creation takes place.
I'm interested to specify that for certain objects, hibernate be allowed to use either a factory or a creation method (newXXX) from the parent within the graph as in:
Foo foo = Foo.Factory.newIntance(); // use the Factory and newInstance method to create new objects
Bar bar = Foo.newBar(); // use the newBar() method of Foo to create and set Bar objects
Bar.setBaz( 123 );
I'm not sure how this plays into collections, etc, but I was wondering if it was possible, where a good entry point might be.