[CDO] Legacy model changes not comitted [message #1426601] |
Fri, 19 September 2014 01:00  |
Roza Ghamari 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   |
Per Sterner 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
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03510 seconds