Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » UUID eattribute conflicts in ECoreUtil.copy (Auto-generate a new UUID at using ECoreUtil.copy)
UUID eattribute conflicts in ECoreUtil.copy [message #986346] Tue, 20 November 2012 03:06 Go to previous message
Paco Blanco is currently offline 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 03:21]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Previous Topic:Order of @Type and @JoinTable can break hibernate mapping
Next Topic:EcoreUtil.equals for xsd:list type
Goto Forum:
  


Current Time: Fri May 24 10:45:55 EDT 2013

Powered by FUDForum. Page generated in 0.01791 seconds