-->
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.  [ 3 posts ] 
Author Message
 Post subject: Migrate from one Subclass to Another
PostPosted: Thu Nov 10, 2005 6:42 pm 
Newbie

Joined: Thu Nov 10, 2005 6:33 pm
Posts: 1
I have a Merchant object. It is subclassed by two objects: ProspectMerchant and ClientMerchant via a joined-subclass. Other objects, like documents and notes are attached to the Merchant. Throughout the life cycle of the system, a ProspectMerchant will be come a ClientMerchant.

What is the correct way to make the transition between one subclass to another? I need to preserve those links to the other objects.

This may be completely obvious, but I'm a newbie when it comes to NHibernate.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 2:54 pm 
Regular
Regular

Joined: Thu May 12, 2005 10:12 am
Posts: 71
Location: Buenos Aires, Argentina
To answer your question you have to first realize that converting form one sublcass to another is impoosible in C# (or Java and many other languages for that matter).

The truth is you should probably look very closely at your design because I think you are confusing certain OO concepts. The kind of "issue" you have with a class mutating are usually solved with a Role pattern.

Good luck and feel free to ask again when you delved a bit more into your design.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 11, 2005 7:47 pm 
Contributor
Contributor

Joined: Thu May 12, 2005 8:45 am
Posts: 226
You could put a static method on ClientMerchant, something like FromProspect(ProspectMerchant), and return a new ClientMerchant object after populating all the properties from the ProspectMerchant.

Or, you could drop the whole heirarchy stuff and put a boolean property IsProspect on your Merchant object. It would start as true and get flipped to false at some point in the system's lifecycle. This assumes, of course, that there are no other differences between all three objects here.


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

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.