I would like to use "separated interface" pattern to code the objects. That is there are two class files for each object, an interface and an implementation. The clients of these objects always refer to the objects by the interface name and not the implementation. They even query based on the interface name instead of the implementation. So the hibernate mapping should refer to the interface.
But it won't work because Hibernate needs a public constructor. I have tried to use the implementation class as <sublass> of the interface but it won't work entirely because I have other inherited classes/interfaces that would have to be mapped with <joined-subclass>.
For Example,
I have 3 interfaces Pet, Cat and Dog. The later two extending the Pet interface. Similary I have 3 implementation classes PetImpl, CatImpl and DogImpl (all of them not abstract) respectively for each interface with the later two extending the PetImpl class. This is somewhat similar to what Eclipse code generator does. I want to map the inheritance between Pet, Cat and Dog using joined-subclass.
How can I direct the Hibernate to instantiate PetImpl class instead of Pet when these are referenced in queries or load or save?
Thanks,
Prasad
|