Skip to main content



      Home
Home » Modeling » EMF » Insulating persisted data from changes to the Ecore model schema
Insulating persisted data from changes to the Ecore model schema [message #767562] Sun, 18 December 2011 05:37 Go to next message
Eclipse UserFriend
Hi,
How can I re-use data that I've persisted earlier, using an older version of my Ecore model schema, after making changes, e.g addition of a new Ecore class and creating a new relationship?

For example, suppose that for the first version, I create a Library class and a Book class. I create the eclipse EMF plugin and create a new library project and add some books to the library.

For the second version, I add an Author class and model the relationship between the Book, Author and Library classes.

I've noticed that after I regenerate the new plugin, I am unable to right click on the Library model element and add a new Author.

I recall a while back that EMF was supposed to help insulate persisted data from changes in the model schema. I vaguely recall that it worked at the time.

But, when I try it now, it doesn't seem to work.

I'm using Eclipse-3.7 SR1 modeling tools SDK bundle on Mac OS X 10.7.2.

Elvis Dowson
Re: Insulating persisted data from changes to the Ecore model schema [message #767608 is a reply to message #767562] Sun, 18 December 2011 08:24 Go to previous messageGo to next message
Eclipse UserFriend
Elvis,

Comments below.

On 18/12/2011 11:37 AM, Elvis Dowson wrote:
> Hi,
> How can I re-use data that I've persisted earlier, using an older
> version of my Ecore model schema, after making changes, e.g addition
> of a new Ecore class and creating a new relationship?
Additions shouldn't be a problem.
>
> For example, suppose that for the first version, I create a Library
> class and a Book class. I create the eclipse EMF plugin and create a
> new library project and add some books to the library.
>
> For the second version, I add an Author class and model the
> relationship between the Book, Author and Library classes.
> I've noticed that after I regenerate the new plugin, I am unable to
> right click on the Library model element and add a new Author.
Did you add a containment reference? (Note if not, and you change it,
you'll still have to change the GenFeature property for Libraries
authors feature.)
>
> I recall a while back that EMF was supposed to help insulate persisted
> data from changes in the model schema. I vaguely recall that it
> worked at the time.
>
> But, when I try it now, it doesn't seem to work.
> I'm using Eclipse-3.7 SR1 modeling tools SDK bundle on Mac OS X 10.7.2.
>
> Elvis Dowson
Re: Insulating persisted data from changes to the Ecore model schema [message #767621 is a reply to message #767608] Sun, 18 December 2011 09:04 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,

Ed Merks wrote on Sun, 18 December 2011 14:24

Did you add a containment reference? (Note if not, and you change it,
you'll still have to change the GenFeature property for Libraries
authors feature.)


I'm using the Ecore Tools plugin to create an Ecore diagram, which creates the library.ecore model. After that I create the *.genmodel file from the library.ecore model file.

I can't seem to find the GenFeature property for either the Ecore diagram or the Ecore model file. Could you please tell me on which model element / model file it is located in?

I did add the Author as a containment relationship, but it gave errors when trying to open the previous model.

Best regards,

Elvis Dowson
Re: Insulating persisted data from changes to the Ecore model schema [message #767633 is a reply to message #767621] Sun, 18 December 2011 09:37 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed,
I tried it once again carefully, and it worked. I don't know what went wrong earlier.

The last time, I'd manually re-load the genmodel, this time around, I noticed that the genmodel was
always in sync with the changes made to the ecore diagram.

I've attached screenshots and the model project with this message. Its working fine now.

I've come across COPE (Coupled Evolution of Metamodels and Models) which takes things a bit further and allows you to build a migrator, to convert models if the meta-model changes.

While building this example, I changed the relationship between Book and Author from "has" to "written_by", and it automatically picked up the changes while loading an older version of the model, which had the "has" relationship.

So, to what extent does EMF actually insulate or preserve existing data, from changes to the meta-model / Ecore model schema?

Best regards,

Elvis Dowson
Re: Insulating persisted data from changes to the Ecore model schema [message #767656 is a reply to message #767633] Sun, 18 December 2011 10:55 Go to previous message
Eclipse UserFriend
Elvis,

As long as you only add things, but no renames or removes, you should be
fine. There are also options like OPTION_RECORD_UNKNOWN_FEATURES that
can help in cases where you really break the serialization.



On 18/12/2011 3:37 PM, Elvis Dowson wrote:
> Hi Ed,
> I tried it once again carefully, and it worked. I don't know what went wrong earlier.
>
> The last time, I'd manually re-load the genmodel, this time around, I noticed that the genmodel was
> always in sync with the changes made to the ecore diagram.
>
> I've attached screenshots and the model project with this message. Its working fine now.
>
> I've come across COPE (Coupled Evolution of Metamodels and Models) which takes things a bit further and allows you to build a migrator, to convert models if the meta-model changes.
>
> While building this example, I changed the relationship between Book and Author from "has" to "written_by", and it automatically picked up the changes while loading an older version of the model, which had the "has" relationship.
>
> So, to what extent does EMF actually insulate or preserve existing data, from changes to the meta-model / Ecore model schema?
>
> Best regards,
>
> Elvis Dowson
Previous Topic:EMF code generator formats code but not comments
Next Topic:How to instantiate objects that have simple association relationships and not containment references
Goto Forum:
  


Current Time: Sat Jul 05 09:42:30 EDT 2025

Powered by FUDForum. Page generated in 0.07590 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top