Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Legacy model changes not comitted
[CDO] Legacy model changes not comitted [message #1426601] Fri, 19 September 2014 01:00 Go to next message
Roza Ghamari is currently offline Roza GhamariFriend
Messages: 82
Registered: January 2013
Member
I am using the Hibernate Store and QuickStart example to programaticaly get my object from server and make some changes and commit the transaction back. My model is a legacy model and I cannot regenrate and make it a CDOModel because the super classes are from alibrary that are not CDO models.

When I run the test with the CDO example model it works fine and it catches the changes and comitts makes the changes. However, when I run the same example on instances of my own model, after the first commit the changes on the model are not caught. As a result when I get the transactioninfo it has no commitdata.

When I try to use the EMF Editor and CDO Session viewer in Eclipse instance to create the model and make changes, it works fine and changes are committed.

I debugged in the code and I saw the isDirty flag doesn't get set when I call the setters in my object. Also, the eNotificationRequired in the setter returns false, which is because no Adapters are registered.

So I am wondering what I need to do to enable CDo on my legacy model for commits and updates programatically.

Also, if there is any way to regernate a cdo model that is extending a non-cdo model please let me know.


The code sample is:

final CDOSession session = openSession();
      final CDOTransaction transaction = session.openTransaction();
      // get/create a resource
      CDOResource resource = transaction.getOrCreateResource("/res4"); 

      // clear any previous data
      resource.getContents().clear(); //this sets the isDIrty to true

       MyClass1 res = MyFactory.eINSTANCE.MyClass1();
       res.setname("name");
       MyClass2 des = MyFactory.eINSTANCE.MyClass2();
       res.setRefObject(des);
       MyClass3 md= MyFactory.eINSTANCE.MyClass3();

       md.setComments("com1");
       md.setContactPerson("roza");
      
      resource.getContents().add(res);

      System.err.println(transaction.commit()); //the first commit works correctly

      md.setComments("new comment");
      md.setDesignDomain("dom1");
      System.err.println(transaction.commit()); //this commit doesn't catch any changes


Thanks,
Roza

[Updated on: Fri, 19 September 2014 01:05]

Report message to a moderator

Re: [CDO] Legacy model changes not comitted [message #1426796 is a reply to message #1426601] Fri, 19 September 2014 08:17 Go to previous messageGo to next message
Per Sterner is currently offline Per SternerFriend
Messages: 91
Registered: October 2011
Member
If des and md only are referenced, they must be contained in a resource.
       ...
       MyClass1 res = MyFactory.eINSTANCE.MyClass1();
       res.setname("name");
       MyClass2 des = MyFactory.eINSTANCE.MyClass2();
       res.setRefObject(des);
       MyClass3 md= MyFactory.eINSTANCE.MyClass3();

       md.setComments("com1");
       md.setContactPerson("roza");
      
      resource.getContents().add(res);
       ...

[Updated on: Fri, 19 September 2014 08:18]

Report message to a moderator

Re: [CDO] Legacy model changes not comitted [message #1426829 is a reply to message #1426601] Fri, 19 September 2014 09:18 Go to previous messageGo to next message
Erdal Karaca is currently offline Erdal KaracaFriend
Messages: 854
Registered: July 2009
Senior Member
Are you changing meta classes and trying to commit "the changes"?

That would be something like this:

- make changes to a file on file system
- String.class.setName("xyz")
- save the file
Re: [CDO] Legacy model changes not comitted [message #1429057 is a reply to message #1426829] Mon, 22 September 2014 18:53 Go to previous messageGo to next message
Roza Ghamari is currently offline Roza GhamariFriend
Messages: 82
Registered: January 2013
Member
both references are containment and also I am not changing metaclass I am just changing the attributes of my object instance. Any other thoughts?

[Updated on: Mon, 22 September 2014 18:54]

Report message to a moderator

Re: [CDO] Legacy model changes not comitted [message #1429461 is a reply to message #1429057] Tue, 23 September 2014 08:58 Go to previous messageGo to next message
Per Sterner is currently offline Per SternerFriend
Messages: 91
Registered: October 2011
Member
You haven't added md anywhere. You can use CDOUtil.getCDOObject(eObject).cdoRevision(); to test if the item is contained anywhere. Or a println on an EObject returns something like Product1[TRANSIENT] <- not contained anywhere or Product1[NEW] <- contained but not commited yet. DIRTY means it is modified.

...
       MyClass3 md= MyFactory.eINSTANCE.MyClass3();

       md.setComments("com1");
       md.setContactPerson("roza");
...
Re: [CDO] Legacy model changes not comitted [message #1429843 is a reply to message #1429461] Tue, 23 September 2014 20:43 Go to previous message
Roza Ghamari is currently offline Roza GhamariFriend
Messages: 82
Registered: January 2013
Member
You are right, with that it worked. I need to see why it is not working with my editor.
I have another problem with ID which I will be positing in a different thread.

Thanks,
Roza
Previous Topic:[XCore] Can I reference a EAtribute of a Xcore model on another Xcore model (within the same package
Next Topic:[CDO] cast error from string to cdoid
Goto Forum:
  


Current Time: Fri Mar 29 11:23:40 GMT 2024

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

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

Back to the top