Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » How to update persisted models after extending
How to update persisted models after extending [message #422955] Fri, 19 September 2008 15:05 Go to next message
Roger Stocker is currently offline Roger StockerFriend
Messages: 16
Registered: July 2009
Junior Member
I wish to update a persisted model which is store via CDO/Hibernate/Teneo.
I added a new feature to a dynamic model eClass.

What needs to be done in order to update the ecore package on the server?

I tried this (lastname is the new EAttribute):

CDOSession session = configuration.openSession();

EClass pClass = EcoreFactory.eINSTANCE.createEClass();
pClass.setName("DynPerson");

EAttribute attribute = EcoreFactory.eINSTANCE.createEAttribute();
attribute.setName("firstName");
attribute.setEType(EcorePackage.eINSTANCE.getEString());
pClass.getEStructuralFeatures().add(attribute);

// This is a new EAttribute
attribute = EcoreFactory.eINSTANCE.createEAttribute();
attribute.setName("lastName");
attribute.setEType(EcorePackage.eINSTANCE.getEString());
pClass.getEStructuralFeatures().add(attribute);

pClass.getEAllStructuralFeatures();

EPackage package1 = EcoreFactory.eINSTANCE.createEPackage();
package1.setName("DynPeople");
package1.setNsPrefix("ch.mycom");
package1.setNsURI("http://my-com.ch/DynPeople");
package1.getEClassifiers().add(pClass);
EPackage.Registry.INSTANCE.put(package1.getNsURI(), package1);

session.getPackageRegistry().putEPackage(package1);

// Open transaction
CDOTransaction transaction = session.openTransaction();

CDOResource resource = transaction.createResource("/Test");

EObject person = package1.getEFactoryInstance().create(pClass);
EStructuralFeature feature = pClass.getEStructuralFeature("firstName");
person.eSet(feature, "Peter");
feature = pClass.getEStructuralFeature("lastName");
person.eSet(feature, "Smith");


The problem is, that the new Attribute is not stored in the DB.

Any clues?

Regards
Roger
Re: How to update persisted models after extending [message #422956 is a reply to message #422955] Fri, 19 September 2008 15:19 Go to previous messageGo to next message
Roger Stocker is currently offline Roger StockerFriend
Messages: 16
Registered: July 2009
Junior Member
sorry, two lines were missing:

resource.getContents().add(person);
transaction.commit();
Re: How to update persisted models after extending [message #422979 is a reply to message #422956] Fri, 19 September 2008 18:37 Go to previous messageGo to next message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Hehe!! It happens!!



"Roger " <r.stocker@gmx.ch> a
Re: How to update persisted models after extending [message #422992 is a reply to message #422979] Sat, 20 September 2008 10:36 Go to previous messageGo to next message
Roger Stocker is currently offline Roger StockerFriend
Messages: 16
Registered: July 2009
Junior Member
I am one step further now. Now I get an Exception:

[ERROR] UnsupportedOperationException
java.lang.UnsupportedOperationException
at
org.eclipse.emf.cdo.server.internal.hibernate.HibernateStore Reader.readRevisionByVersion(HibernateStoreReader.java:169)
at
org.eclipse.emf.cdo.internal.server.RevisionManager.loadRevi sionByVersion(RevisionManager.java:223)
at
org.eclipse.emf.cdo.internal.common.revision.CDORevisionReso lverImpl.getRevisionByVersion(CDORevisionResolverImpl.java:1 61)
at
org.eclipse.emf.cdo.internal.common.revision.CDORevisionReso lverImpl.getRevisionByVersion(CDORevisionResolverImpl.java:1 )
at
org.eclipse.emf.cdo.internal.server.TransactionCommitContext Impl.computeDirtyObject(TransactionCommitContextImpl.java:34 0)
at
org.eclipse.emf.cdo.internal.server.TransactionCommitContext Impl.computeDirtyObjects(TransactionCommitContextImpl.java:3 26)
at
org.eclipse.emf.cdo.internal.server.TransactionCommitContext Impl.write(TransactionCommitContextImpl.java:225)
at
org.eclipse.emf.cdo.internal.server.protocol.CommitTransacti onIndication.indicatingCommit(CommitTransactionIndication.ja va:167)
at
org.eclipse.emf.cdo.internal.server.protocol.CommitTransacti onIndication.indicating(CommitTransactionIndication.java:68)
at
org.eclipse.emf.cdo.internal.server.protocol.CDOServerIndica tion.indicating(CDOServerIndication.java:116)
at org.eclipse.net4j.signal.Indication.execute(Indication.java: 48)
at
org.eclipse.net4j.signal.IndicationWithResponse.execute(Indi cationWithResponse.java:38)
at org.eclipse.net4j.signal.Signal.runSync(Signal.java:186)
at org.eclipse.net4j.signal.Signal.run(Signal.java:167)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unkno wn Source)
at java.butil.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)


In the source of HibernateStoreReader I see:
public CDORevision readRevisionByVersion(CDOID id, int referenceChunk,
int version)
{
// TODO Could be necessary to implement
throw new UnsupportedOperationException();
}


So this should probably be implemented. I'll make a bugzilla.
Re: How to update persisted models after extending [message #422993 is a reply to message #422992] Sat, 20 September 2008 13:15 Go to previous message
Simon Mc Duff is currently offline Simon Mc DuffFriend
Messages: 596
Registered: July 2009
Senior Member
Can you open a bugzilla for that problem ?


"Roger " <r.stocker@gmx.ch> a
Previous Topic:Re: Generating ecore model code with maven or ant
Next Topic:[CDO] Does Store Supports readByVersion ?
Goto Forum:
  


Current Time: Sat Jan 25 04:21:12 GMT 2020

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

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

Back to the top