Hello Werner,

> does anybody know how to change the class of an existing persistent
> object ?

> [SNIP]

> 
> class a
>|              |
> class b    class c
>|
> class n
> 
> I have data in class b - need class n ... move data ?


you have to you class-casting:

s oldInstanceB = ##class(classB).%OpenId(1)
s newInstanceN = ##class(=classN)(oldInstaceB).%ConstructClone(0)
 
> Later on may be I have data in class n ... move up to class b or even
> class c ?

s oldInstanceN = ##class(classN).%OpenId(1)
s newInstanceC = ##class(=classC)(oldInstaceN).%ConstructClone(0)

I think that solves your problem.

If you want the dependent objects to be Cloned also, you can use 
%ContructClone(1). But be careful - it really clones every object 
referenced from your object.

Take a look at the documentation of %ConstructClone()!!

Florian Backes




Reply via email to