UUID eattribute conflicts in ECoreUtil.copy [message #986346] |
Tue, 20 November 2012 08:06 |
Paco Blanco Messages: 28 Registered: June 2012 |
Junior Member |
|
|
Hello,
I am using an EClass with a String EAttribute that relates to an UUID. I do not know if my way to set the UUID value is good but I initialize it in the constructor:
protected Constructor() {
super();
setUUID(EcoreUtil.generateUUID());
}
The setUUID is the setter autogenerated by the EMF generator code.
When I do a copy of an element using EcoreUtil.copy(EObject), I want the generated new element has a different UUID because this new element is a different instance. Unluckily, although the contructor sets a new value just generated, the Copier overwrittes the value with the same value of the element to copy.
My first attempt to solve it is to put the changeable property of the EAttribute to false and convert the attribute to a final variable. But I do not know to put the value of the generateUUID() to the attribute: the setter has been deleted (logically) but all types of eSet give me an exception around to impossible change the value of a not changeable feature.
Some solution?
[Updated on: Tue, 20 November 2012 08:21] Report message to a moderator
|
|
|
|
|
Re: UUID eattribute conflicts in ECoreUtil.copy [message #986818 is a reply to message #986673] |
Wed, 21 November 2012 18:08 |
Ed Merks Messages: 33142 Registered: July 2009 |
Senior Member |
|
|
Paco,
There are two different feature delegation patterns, Reflective and
Dynamic. If you use Reflective, the Reflective, the eGet methods should
delete to your specialized getter.
On 21/11/2012 11:47 AM, Paco Blanco wrote:
> Thanks for advices
> Specialized Copier ignoring my efeatures works without problems
> Unluckly, I use CDO as persistent technology and the new eObject just
> copied sets a null in the UUID column in DB if I move the
> setUUID(EcoreUtil.generateUUID()) to getter method. I think CDO
> directly uses emf reflection by eGet and ignores the top getter of the
> EClass.
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.06299 seconds