‎2007 Sep 12 11:27 AM
Hi all,
How can I make persistent a previously created transient object? I mean, is there any other way of making it persistent instead of executing method CREATE_PERSISTENT( attributes ) ??
Maybe something like:
MyTransientObject = Agent->Create_Transient( ... )
...
MyTransientObject->MakePersistent( )
Thanks in advance.
‎2007 Sep 14 12:48 AM
Hi Jorge,
what I was suggesting was to just call the create_persistent method with the attributes of the transient object except the business key. Then you will get a new business key for the persistent object. Then overwrite the reference to the transient object with the new persistent object reference.
Something like this.
MyTransientObject = Agent->Create_Transient( ... )
...
MyPersistentObject = Agent->Create_Persistent( ... ).
MyTransientObject ?= MyPersistentObject.Cheers
Graham
‎2007 Sep 12 11:57 PM
Hi Jorge,
it seems not. I have just looked through the doco and has a quick play and I can't see any inbuilt method to do this. I guess you just need to code your own MakePersistent method to do this.
Cheers
Graham
‎2007 Sep 13 9:13 AM
Thanks Graham,
unfortunately, if I try to create one persistent object from an already created transient object, an error occurs due to business key already is used by my transient object.
Persistent and Transient objects verify if business key is already being used.
So it seems that is not possible to create persistent objects from transient ones.
If this is correct, I don't know when to use transient objects, just for avoiding to create more than one object with same business key???
‎2007 Sep 13 9:59 AM
Hi Jorge,
you should be able to create a new persistent object with all the attributes of the transient object except the business key.
You then just need to update the object reference to the transient key to point to the instance of the new persistent object.
Cheers
Graham
‎2007 Sep 13 3:46 PM
Hi Graham,
I think your solution will not work, I guess I can't create a persistent object without business key; even if this is possible, business key is not modifiable, its only allowed to set value to the business key in CONSTRUCTOR methods, there are no SET methods for it.
Thanks again.
‎2007 Sep 14 12:48 AM
Hi Jorge,
what I was suggesting was to just call the create_persistent method with the attributes of the transient object except the business key. Then you will get a new business key for the persistent object. Then overwrite the reference to the transient object with the new persistent object reference.
Something like this.
MyTransientObject = Agent->Create_Transient( ... )
...
MyPersistentObject = Agent->Create_Persistent( ... ).
MyTransientObject ?= MyPersistentObject.Cheers
Graham