Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » CDOServerImporter throws Unique index or primary key violation(CDOServerImporter throws Unique index or primary key violation)
CDOServerImporter throws Unique index or primary key violation [message #1022886] Fri, 22 March 2013 18:11 Go to next message
Andrew Whelan is currently offline Andrew WhelanFriend
Messages: 69
Registered: October 2012
Location: Syracuse NY
Member
Hello,
I am trying to use CDOServerExport.XML to export data from an H2 repository to an XML file and then import it (using CDOServerImport.XML) to a repository of a different name. When I run the import (to import the file that was exported) a "Unique index or primary key violation" exception is thrown. It is shown at the bottom of this message.

I have attached one file of Java code and the CDO Server configuration file.
I am using the org.eclipse.emf.cdo.server.product.tcp_h2 product as a server. I am using the Company example plugin.

I run 4 methods from the main() method of the code. I comment out what I am not running at a particular time. Directions are as follows.

1)Start up the CDO server using a Run Configuration as described in the following tutorial: http://www.rcp-vision.com/?p=1285&lang=en

2)Uncomment the populate() and get() methods in the main(). This will populate the database with a few records and print the names of the companies and customers. Run the application.

3)Shut down the CDO Server.

4)Comment out the populate() and get() methods in the main(). Uncomment the Export() method in the main (I have a hard coded path for the export file). Run the application.

5)Delete the H2 database top level directory. (this step should be optional as I am
using a different repository name for the import).

6)Comment out the Export() method in the main(). Uncomment the Import() method in the main(). When I run the application I get the following exception.
Any ideas? Is it a bug? Thanks!

org.eclipse.net4j.db.DBException: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "I1363973975334_3 ON PUBLIC.CDO_PACKAGE_UNITS(ID)"; SQL statement:
INSERT INTO cdo_package_units VALUES (?, ?, ?, ?) [23505-168]
at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.fillSystemTables(MetaDataManager.java:262)
at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.fillSystemTables(MetaDataManager.java:291)
at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.writePackageUnits(MetaDataManager.java:138)
at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writePackageUnits(DBStoreAccessor.java:826)
at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.rawStore(DBStoreAccessor.java:1240)
at org.eclipse.emf.cdo.server.CDOServerImporter$FlushHandler.handleModels(CDOServerImporter.java:240)
at org.eclipse.emf.cdo.server.CDOServerImporter$XML$XMLHandler.endElement(CDOServerImporter.java:548)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2939)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
at org.eclipse.emf.cdo.server.CDOServerImporter$XML.importAll(CDOServerImporter.java:329)
at org.eclipse.emf.cdo.server.CDOServerImporter.importRepository(CDOServerImporter.java:111)
at org.eclipse.example.library.tests.TestCDOH2.Import(TestCDOH2.java:203)
at org.eclipse.example.library.tests.TestCDOH2.main(TestCDOH2.java:246)
Caused by: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "I1363973975334_3 ON PUBLIC.CDO_PACKAGE_UNITS(ID)"; SQL statement:
INSERT INTO cdo_package_units VALUES (?, ?, ?, ?) [23505-168]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
at org.h2.message.DbException.get(DbException.java:169)
at org.h2.message.DbException.get(DbException.java:146)
at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:81)
Re: CDOServerImporter throws Unique index or primary key violation [message #1031007 is a reply to message #1022886] Mon, 01 April 2013 03:56 Go to previous messageGo to next message
Eike Stepper is currently offline Eike StepperFriend
Messages: 5574
Registered: July 2009
Senior Member
Hi Andrew,

Sorry for the late reply, I've just returned from the EclipseCon in Boston.

Is it possible that you provide me with a test case similar to the ones in org.eclipse.emf.cdo.tests.BackupTest?

Cheers
/Eike

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


Am 22.03.2013 19:11, schrieb Andrew Whelan:
> Hello,
> I am trying to use CDOServerExport.XML to export data from an H2 repository to an XML file and then import it (using CDOServerImport.XML) to a repository of a different name. When I run the import (to import the file that was exported) a "Unique index or primary key violation" exception is thrown. It is shown at the bottom of this message.
>
> I have attached one file of Java code and the CDO Server configuration file.
> I am using the org.eclipse.emf.cdo.server.product.tcp_h2 product as a server. I am using the Company example plugin.
>
> I run 4 methods from the main() method of the code. I comment out what I am not running at a particular time. Directions are as follows.
>
> 1)Start up the CDO server using a Run Configuration as described in the following tutorial: http://www.rcp-vision.com/?p=1285&lang=en
>
> 2)Uncomment the populate() and get() methods in the main(). This will populate the database with a few records and print the names of the companies and customers. Run the application.
>
> 3)Shut down the CDO Server.
>
> 4)Comment out the populate() and get() methods in the main(). Uncomment the Export() method in the main (I have a hard coded path for the export file). Run the application.
>
> 5)Delete the H2 database top level directory. (this step should be optional as I am
> using a different repository name for the import).
>
> 6)Comment out the Export() method in the main(). Uncomment the Import() method in the main(). When I run the application I get the following exception.
> Any ideas? Is it a bug? Thanks!
>
> org.eclipse.net4j.db.DBException: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "I1363973975334_3 ON PUBLIC.CDO_PACKAGE_UNITS(ID)"; SQL statement:
> INSERT INTO cdo_package_units VALUES (?, ?, ?, ?) [23505-168]
> at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.fillSystemTables(MetaDataManager.java:262)
> at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.fillSystemTables(MetaDataManager.java:291)
> at org.eclipse.emf.cdo.server.internal.db.MetaDataManager.writePackageUnits(MetaDataManager.java:138)
> at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.writePackageUnits(DBStoreAccessor.java:826)
> at org.eclipse.emf.cdo.server.internal.db.DBStoreAccessor.rawStore(DBStoreAccessor.java:1240)
> at org.eclipse.emf.cdo.server.CDOServerImporter$FlushHandler.handleModels(CDOServerImporter.java:240)
> at org.eclipse.emf.cdo.server.CDOServerImporter$XML$XMLHandler.endElement(CDOServerImporter.java:548)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2939)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:647)
> at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
> at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
> at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
> at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
> at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
> at javax.xml.parsers.SAXParser.parse(SAXParser.java:198)
> at org.eclipse.emf.cdo.server.CDOServerImporter$XML.importAll(CDOServerImporter.java:329)
> at org.eclipse.emf.cdo.server.CDOServerImporter.importRepository(CDOServerImporter.java:111)
> at org.eclipse.example.library.tests.TestCDOH2.Import(TestCDOH2.java:203)
> at org.eclipse.example.library.tests.TestCDOH2.main(TestCDOH2.java:246)
> Caused by: org.h2.jdbc.JdbcSQLException: Unique index or primary key violation: "I1363973975334_3 ON PUBLIC.CDO_PACKAGE_UNITS(ID)"; SQL statement:
> INSERT INTO cdo_package_units VALUES (?, ?, ?, ?) [23505-168]
> at org.h2.message.DbException.getJdbcSQLException(DbException.java:329)
> at org.h2.message.DbException.get(DbException.java:169)
> at org.h2.message.DbException.get(DbException.java:146)
> at org.h2.index.BaseIndex.getDuplicateKeyException(BaseIndex.java:81)
>
Re: CDOServerImporter throws Unique index or primary key violation [message #1032946 is a reply to message #1031007] Wed, 03 April 2013 17:04 Go to previous messageGo to next message
Andrew Whelan is currently offline Andrew WhelanFriend
Messages: 69
Registered: October 2012
Location: Syracuse NY
Member
Hi Eike,

After looking the org.eclipse.emf.cdo.tests.BackupTest, it appears that this stuff is only being tested using MEMStore? I doesn't appear that BackupTest is testing using DBStore. Does this sound like it could be correct?

Thanks!

-Andrew
Re: CDOServerImporter throws Unique index or primary key violation [message #1034379 is a reply to message #1032946] Fri, 05 April 2013 11:13 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 5574
Registered: July 2009
Senior Member
Am 03.04.2013 19:04, schrieb Andrew Whelan:
> Hi Eike,
> After looking the org.eclipse.emf.cdo.tests.BackupTest, it appears that this stuff is only being tested using
> MEMStore? I doesn't appear that BackupTest is testing using DBStore. Does this sound like it could be correct?
No, compare
https://hudson.eclipse.org/hudson/job/emf-cdo-integration/lastCompletedBuild/testReport/org.eclipse.emf.cdo.tests.db.AllTestsDBH2All$Scenario%5BCombined,%20H2-branching,%20JVM,%20Native%5D$org.eclipse.emf.cdo.tests/BackupTest

You can't tell by just looking at the test case. You need to run one of our test suites that configure specifc scenarios
for all tests, e.g., "CDO AllTests (H2 branching)".

Cheers
/Eike

----
http://www.esc-net.de
http://thegordian.blogspot.com
http://twitter.com/eikestepper
Previous Topic:[CDO] Commit data and its meta model => unresolved proxy error
Next Topic:[CDO] Get last commit info from a CDO Object
Goto Forum:
  


Current Time: Fri Nov 28 16:16:47 GMT 2014

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

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