Just started using Hibernate 3.2. I have a strange requirement (I think!) that I can't seem to be able to solve. I have a legacy application using Hibernate 3.2 that I need to customize.
Class "C1" is mapped to Table "T1" and both of them can NOT be modified. Class "C1" is being used by the legacy bussiness layer.
So, I would like to write a class "C2" that extends class "C1" and add a new attribute. It would mean adding a <set> of <composite-element> in the hibernate mapping file. The collection should resolve to table "T2".
// Existing mapping
<class name="C1" table="T1">
...
</class>
// The new class I wrote
class C2 extends C1 {
Set addresses;
//... has getAddresses and setAddresses
}
What I am hoping for is a construct in the mapping file to say,
<class name="C2" extends="C1">
<set name="addresses" table="T2"> ... </set>
</class>
My concern is: How do I ensure that the existing code continues to work with class "C1" and the new code works with both class "C1" and class "C2" at the same time?
Ideally: Is there a way to tell Hibernate to transparently return "C2" ALL the time even from the methods in the existing code that were returning instances of "C1" ?
I am not sure if what am I asking for even makes sense.
Please help!
Thanks
A lost new user!
Last edited by newhibuser on Thu May 01, 2008 6:41 pm, edited 3 times in total.
|