Reputation: 21
I am creating an ECore model. I created an EClass and inside it I want to create a data member that is a list. So I created an EAttribute of type EEList.
However when I try to create the genmodel file I get an error saying
the attribute "XYZ.Attribute_name" is not transient o it must have a data type that is serializable.
It also gives a warning saying
The generic type associated with the 'EEList' classifier should have 1 type atrgument(s) to match the number of type parameter(s) of the classifier.
Can anyone tell me what I'm doing wrong? I could not figure out how to set the E
in EEList<E>
.
Upvotes: 1
Views: 449
Reputation: 12122
The first error probably disappears after you've fix the second error. I write an explanation here, but you probably don't have to deal with it to solve you problem.
It is because, to be saved to disk, the EDataTypes of attributes must be convertible to a text format.
There are two ways to ensure this:
Serializable
interface and provide serializating operations. Many standard Java classes, such as String
and Integer
already do that.Another solution is to set the Transient property of the attribute to true. The the attribute will not be saved and its EDataType does not need to be serialized.
The normal way to create a list attribute is to set the Upper Bound property of the attribute to a value different from 1. To create a list attribute which can contain any number of elements, set Upper Bound to -1, which means Unbounded.
The EAttribute Type should be set to the element type, not to a list type.
The generated Java code will contain a property with the type EList<ElementType>
.
Upvotes: 1