If you really need this functionality you probably could update the table manually. Assuming that you're using the table-per-inheritance this isn't that bad. (Where both vendor and person are in the same table.)
You'll have a row in the db like ID, Subclass, Version, Name, Birthday, Address ... 33, STK.Entities.Person, Bob, 1/1/85, 1234... You could just manually change this to: 33, STK.Entities.Vendor, Bob, 1/1/85, 1234... Not sure that it would be the best idea ever... as it is going to break things if you have default values set up in your vendor class. It might break other things too... I haven't tried this it's just a crazy idea. You'll only want to do this when you have NOT loaded this entity with NH. You can load it to get the ID, then close out your session so it isn't loaded, update, reload. Good luck. On Fri, Apr 3, 2009 at 5:40 AM, stk <[email protected]> wrote: > > Hello all, > I have the following situation. A person can be both student and > vendor. Let's say that I save the person first, and after that the > person becomes a vendor. Using inheritance in NHibernate (mapped as > table per class) i cannot save the person first, and make that person > entity also a vendor. I understand the NHibernate team which says that > you cannot change the type of an object (.NET object for example) once > the object has been created. But, what if I ask the NHibernate session > "get me the object vendor with the id of the object person" and then, > the session, even though sees that the vendor does not exist, sees > also that the person (which is the superclass of vendor) exists, and > gives me a vendor object with the properties from person filled in and > after that the vendor object can be persisted into the database? > This post is addressed mainly to the NHibernate team, so any follow up > from them will be appreciated. > Thanks. > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/nhusers?hl=en -~----------~----~----~----~------~----~------~--~---
