Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [EMF] [CDO] What is the proper way to commit EClass instance to CDO server?
[EMF] [CDO] What is the proper way to commit EClass instance to CDO server? [message #891644] Mon, 25 June 2012 12:03 Go to next message
Thanapol R. is currently offline Thanapol R.Friend
Messages: 3
Registered: July 2009
Junior Member
I tried to create an EClass instance using org.eclipse.em.ecore.EcoreFactory.createEClass() and add it to the CDO server with the following code

...
//create configuration
...
CDONet4jSession session = configuration.openNet4jSession();
session.getPackageRegistry().putEPackage(EcorePackage.eINSTANCE);
CDOTransaction trans = session.openTransaction();

try {
	Resource resource = trans.getOrCreateResource("umlresource");
	EClass eObject = EcoreFactory.eINSTANCE.createEClass();
	eObject.setName("MyClass");
	resource.getContents().add(eObject);
	trans.commit();
}
finally {
	if (trans != null) {
		trans.close();
        }
	if (session != null) {
		session.close();
	}
	container.deactivate();
}


The exception I've got is

Quote:
[ERROR] Rollback in DBStore: org.eclipse.net4j.db.DBException: org.h2.jdbc.JdbcSQLException: Table ECORE_ECLASS not found; SQL statement:
INSERT INTO ecore_EClass(cdo_id, cdo_version, cdo_branch, cdo_created, cdo_revised, cdo_resource, cdo_container, cdo_feature, name, instanceClassName, instanceTypeName, ePackage, abstract, interface, cdo_set_instanceClassName, cdo_set_instanceTypeName, eAnnotations, eTypeParameters, eOperations, eStructuralFeatures, eGenericSuperTypes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [42102-117]
at org.eclipse.emf.cdo.server.internal.db.SmartPreparedStatementCache.createCachedPreparedStatement(SmartPreparedStatementCache.java:84)
at org.eclipse.emf.cdo.server.internal.db.SmartPreparedStatementCache.getPreparedStatement(SmartPreparedStatementCache.java:43)
at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.writeValues(HorizontalBranchingClassMapping.java:602)
at org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.writeRevision(HorizontalBranchingClassMapping.java:804)
at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writeRevision(DBStoreAccessor.java:583)
at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writeRevisions(DBStoreAccessor.java:563)
at org.eclipse.emf.cdo.spi.server.StoreAccessor.doWrite(StoreAccessor.java:94)
at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:149)
at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:487)
at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:43)
at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:1)
at org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:262)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:96)
at org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.indicating(CDOServerIndicationWithMonitoring.java:109)
at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:84)
at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedInput(IndicationWithResponse.java:90)
at org.eclipse.net4j.signal.Signal.doInput(Signal.java:326)
at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:63)
at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:63)
at org.eclipse.net4j.signal.Signal.runSync(Signal.java:251)
at org.eclipse.net4j.signal.Signal.run(Signal.java:147)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:680)
Caused by: org.h2.jdbc.JdbcSQLException: Table ECORE_ECLASS not found; SQL statement:
INSERT INTO ecore_EClass(cdo_id, cdo_version, cdo_branch, cdo_created, cdo_revised, cdo_resource, cdo_container, cdo_feature, name, instanceClassName, instanceTypeName, ePackage, abstract, interface, cdo_set_instanceClassName, cdo_set_instanceTypeName, eAnnotations, eTypeParameters, eOperations, eStructuralFeatures, eGenericSuperTypes) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [42102-117]
at org.h2.message.Message.getSQLException(Message.java:105)
at org.h2.message.Message.getSQLException(Message.java:116)
at org.h2.message.Message.getSQLException(Message.java:75)
at org.h2.command.Parser.readTableOrView(Parser.java:4265)
at org.h2.command.Parser.readTableOrView(Parser.java:4245)
at org.h2.command.Parser.parseInsert(Parser.java:888)
at org.h2.command.Parser.parsePrepared(Parser.java:368)
at org.h2.command.Parser.parse(Parser.java:290)
at org.h2.command.Parser.parse(Parser.java:262)
at org.h2.command.Parser.prepareCommand(Parser.java:234)
at org.h2.engine.Session.prepareLocal(Session.java:415)
at org.h2.engine.Session.prepareCommand(Session.java:376)
at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1049)
at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:74)
at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:233)
at org.eclipse.emf.cdo.server.internal.db.SmartPreparedStatementCache.createCachedPreparedStatement(SmartPreparedStatementCache.java:79)
...
24 more




I use CDO 4.1-RC3 (S20120605-0730).
Do I miss something?

Thank in advanced
Re: [EMF] [CDO] What is the proper way to commit EClass instance to CDO server? [message #891695 is a reply to message #891644] Mon, 25 June 2012 14:14 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6457
Registered: July 2009
Senior Member
Am 25.06.2012 14:03, schrieb Thanapol R.:
> I tried to create an EClass instance using org.eclipse.em.ecore.EcoreFactory.createEClass() and add it to the CDO
> server with the following code
>
> ..
> //create configuration
> ..
> CDONet4jSession session = configuration.openNet4jSession();
> session.getPackageRegistry().putEPackage(EcorePackage.eINSTANCE);
That's not needed. Ecore is always registered. In general generated models do not need to be registered with CDOSessions
if the extension registry is functional.

> CDOTransaction trans = session.openTransaction();
Make sure that the legacy mode is switched on:

assertTrue(trans.isLegacyModeEnabled());

> try {
> Resource resource = trans.getOrCreateResource("umlresource");
> EClass eObject = EcoreFactory.eINSTANCE.createEClass();
> eObject.setName("MyClass");
> resource.getContents().add(eObject);
> trans.commit();
> }
> finally {
> if (trans != null) {
> trans.close();
> }
That's implicitely done when the session is closed.

> if (session != null) {
> session.close();
> }
> container.deactivate();
> }
>
> The exception I've got is
>
> Quote:
>> [ERROR] Rollback in DBStore: org.eclipse.net4j.db.DBException: org.h2.jdbc.JdbcSQLException: Table ECORE_ECLASS not
>> found;
And with the DBStore you need to set:

<property name="supportingEcore" value="true"/>

Does that help?

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper



>> SQL statement:
>> INSERT INTO ecore_EClass(cdo_id, cdo_version, cdo_branch, cdo_created, cdo_revised, cdo_resource, cdo_container,
>> cdo_feature, name, instanceClassName, instanceTypeName, ePackage, abstract, interface, cdo_set_instanceClassName,
>> cdo_set_instanceTypeName, eAnnotations, eTypeParameters, eOperations, eStructuralFeatures, eGenericSuperTypes) VALUES
>> (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [42102-117]
>> at
>> org.eclipse.emf.cdo.server.internal.db.SmartPreparedStatementCache.createCachedPreparedStatement(SmartPreparedStatementCache.java:84)
>> at
>> org.eclipse.emf.cdo.server.internal.db.SmartPreparedStatementCache.getPreparedStatement(SmartPreparedStatementCache.java:43)
>> at
>> org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.writeValues(HorizontalBranchingClassMapping.java:602)
>> at
>> org.eclipse.emf.cdo.server.internal.db.mapping.horizontal.HorizontalBranchingClassMapping.writeRevision(HorizontalBranchingClassMapping.java:804)
>> at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writeRevision(DBStoreAccessor.java:583)
>> at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writeRevisions(DBStoreAccessor.java:563)
>> at org.eclipse.emf.cdo.spi.server.StoreAccessor.doWrite(StoreAccessor.java:94)
>> at org.eclipse.emf.cdo.spi.server.StoreAccessorBase.write(StoreAccessorBase.java:149)
>> at org.eclipse.emf.cdo.internal.server.TransactionCommitContext.write(TransactionCommitContext.java:487)
>> at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:43)
>> at org.eclipse.emf.cdo.spi.server.InternalCommitContext$1.runLoop(InternalCommitContext.java:1)
>> at org.eclipse.net4j.util.om.monitor.ProgressDistributor.run(ProgressDistributor.java:96)
>> at
>> org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicatingCommit(CommitTransactionIndication.java:262)
>> at
>> org.eclipse.emf.cdo.server.internal.net4j.protocol.CommitTransactionIndication.indicating(CommitTransactionIndication.java:96)
>> at
>> org.eclipse.emf.cdo.server.internal.net4j.protocol.CDOServerIndicationWithMonitoring.indicating(CDOServerIndicationWithMonitoring.java:109)
>> at org.eclipse.net4j.signal.IndicationWithMonitoring.indicating(IndicationWithMonitoring.java:84)
>> at org.eclipse.net4j.signal.IndicationWithResponse.doExtendedInput(IndicationWithResponse.java:90)
>> at org.eclipse.net4j.signal.Signal.doInput(Signal.java:326)
>> at org.eclipse.net4j.signal.IndicationWithResponse.execute(IndicationWithResponse.java:63)
>> at org.eclipse.net4j.signal.IndicationWithMonitoring.execute(IndicationWithMonitoring.java:63)
>> at org.eclipse.net4j.signal.Signal.runSync(Signal.java:251)
>> at org.eclipse.net4j.signal.Signal.run(Signal.java:147)
>> at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
>> at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
>> at java.lang.Thread.run(Thread.java:680)
>> Caused by: org.h2.jdbc.JdbcSQLException: Table ECORE_ECLASS not found; SQL statement:
>> INSERT INTO ecore_EClass(cdo_id, cdo_version, cdo_branch, cdo_created, cdo_revised, cdo_resource, cdo_container,
>> cdo_feature, name, instanceClassName, instanceTypeName, ePackage, abstract, interface, cdo_set_instanceClassName,
>> cdo_set_instanceTypeName, eAnnotations, eTypeParameters, eOperations, eStructuralFeatures, eGenericSuperTypes) VALUES
>> (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [42102-117]
>> at org.h2.message.Message.getSQLException(Message.java:105)
>> at org.h2.message.Message.getSQLException(Message.java:116)
>> at org.h2.message.Message.getSQLException(Message.java:75)
>> at org.h2.command.Parser.readTableOrView(Parser.java:4265)
>> at org.h2.command.Parser.readTableOrView(Parser.java:4245)
>> at org.h2.command.Parser.parseInsert(Parser.java:888)
>> at org.h2.command.Parser.parsePrepared(Parser.java:368)
>> at org.h2.command.Parser.parse(Parser.java:290)
>> at org.h2.command.Parser.parse(Parser.java:262)
>> at org.h2.command.Parser.prepareCommand(Parser.java:234)
>> at org.h2.engine.Session.prepareLocal(Session.java:415)
>> at org.h2.engine.Session.prepareCommand(Session.java:376)
>> at org.h2.jdbc.JdbcConnection.prepareCommand(JdbcConnection.java:1049)
>> at org.h2.jdbc.JdbcPreparedStatement.<init>(JdbcPreparedStatement.java:74)
>> at org.h2.jdbc.JdbcConnection.prepareStatement(JdbcConnection.java:233)
>> at
>> org.eclipse.emf.cdo.server.internal.db.SmartPreparedStatementCache.createCachedPreparedStatement(SmartPreparedStatementCache.java:79)
>> ... 24 more
>
>
>
>
> I use CDO 4.1-RC3 (S20120605-0730).
> Do I miss something?
>
> Thank in advanced


Re: [EMF] [CDO] What is the proper way to commit EClass instance to CDO server? [message #891798 is a reply to message #891644] Tue, 26 June 2012 04:03 Go to previous messageGo to next message
Thanapol R. is currently offline Thanapol R.Friend
Messages: 3
Registered: July 2009
Junior Member
It works.

Thank you
Thanapol R.
Re: [EMF] [CDO] What is the proper way to commit EClass instance to CDO server? [message #891799 is a reply to message #891695] Tue, 26 June 2012 04:04 Go to previous message
Thanapol R. is currently offline Thanapol R.Friend
Messages: 3
Registered: July 2009
Junior Member
It works.

Thank you
Thanapol R.
Previous Topic:[CDO] CDOResource.eResource() creates an infinite loop in EMF EditingDomains
Next Topic:Compatible EMF version for Eclipse 3.7.2 Indigo
Goto Forum:
  


Current Time: Fri Dec 13 00:49:04 GMT 2019

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

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

Back to the top