I've recently begun to use aspects in Documentum and from what I read it seamed that you always have to reload the object after you attach an aspect. Some sources:
In the Documentum Development Guide D65 I found this :
// Attach the aspect.
((IDfAspects)doc).attachAspect("customer_service_aspect",null);
// Save the document.
doc.save();
// Get the document with its newly attached aspect.
doc = (IDfDocument)mySession.getObject(doc.getObjectId());
Here I found this :
- To work with the Aspect attached to
my_obj
you must re-fetch the object immediately after applying the Aspect.
((IDfAspects) my_obj).attachAspect(“my_aspect”,null);
my_obj= (IDfDocument) session.getObject(my_obj.getObjectId());
And here at the bottom of the page:
If you are a regular client just use the sequence ..
(IDfAspects) obj).attachAspect(³foo², null);
IFoo = (IFoo) session.getObject(object.getObjectId());
The reason you have to do the getObject is that the aspect magic causes the actual Java object (obj) to become ³stale² in a special way (we don¹t have
time;-), and the object id, along with all its related state is reconstituted in a new Java object (which alone has the new interface).
getObject recovers a reference to this new Java object, you are happy, and the old one just fades away.
The thing is that I (accidentally) ran :
IDfDocument doc = (IDfDocument) mySession.getObject(new DfId("092e797d80097019"));
((IDfAspects) doc).attachAspect("dm_logical_version", null);
doc.setString("dm_logical_version.logical_version", "v0.1");
doc.save();
and it worked. No errors and the attribute saved in the repository. I'm interested only in saving some attributes (no behavior at the moment) and I'm wondering if you can get unexpected behavior if you set an aspect attribute without reloading the object after attaching the aspect?
Thanks in advance!
Bogdan