-->
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.  [ 1 post ] 
Author Message
 Post subject: Extending a legacy persistent class with multiple mappings
PostPosted: Wed Apr 30, 2008 2:01 pm 
Newbie

Joined: Tue Apr 29, 2008 1:11 pm
Posts: 4
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.

Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.