Jump to content
McObject Forums

Search the Community

Showing results for tags 'xml'.

More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • McObject Embedded Databases
    • Perst
  • Root2


  • Steven Graves' Blog

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start





Website URL







Found 2 results

  1. Hi all, if you export a Perst database to an XML file, and then import it back, the millisecond parts in all java.util.Date objects imported are always zero :-( Regards, Vladimir
  2. Hi support, I have a problem reading back XML created by Perst. My root object contains an index with two string keys. The database seems to operate Ok, I can successfully export it as XML. The resulting XML looks Ok either. But I got the following exception when I try to read it back: org.garret.perst.StorageError: Incompatible key type at org.garret.perst.impl.Btree.checkKey(Btree.java:109) at org.garret.perst.impl.Btree.insert(Btree.java:180) at org.garret.perst.impl.XMLImporter.createIndex(XMLImporter.java:509) at org.garret.perst.impl.XMLImporter.importDatabase(XMLImporter.java:60) at org.garret.perst.impl.StorageImpl.importXML(StorageImpl.java:2643) at testperst.TestRepository.testXmlImport(TestRepository.java:43) ... I use perst-436.jar. My root class is as follows: package testperst; import org.eclipse.jdt.annotation.NonNull; import org.garret.perst.IPersistent; import org.garret.perst.Index; import org.garret.perst.Key; import org.garret.perst.Persistent; import org.garret.perst.Storage; public class MyRoot extends Persistent { public MyRoot() { } public MyRoot(@NonNull Storage storage) { super(storage); rootIndex = storage.createIndex(new @NonNull Class [] {String.class, String.class}, true); } public void put(@NonNull IPersistent o, @NonNull String a, @NonNull String { @NonNull Key key = new Key(new Object[]{a, b}); rootIndex.put(key, o); } private Index rootIndex; } The test class is: package testperst; import java.io.BufferedReader; public class TestRepository { @Test public void testInitDB() throws Exception { Storage db = getStorage(); getRootIndex(db); db.close(); } @Test public void testXmlExport() throws Exception { Storage db = getStorage(); assert db != null; try { Writer writer = new BufferedWriter(new FileWriter("/tmp/testPerst.xml")); db.exportXML(writer); writer.close(); } catch (IOException x) { System.err.println("Export failed: " + x); } db.close(); } @Test public void testXmlImport() throws Exception { Storage db = getStorage(); assert db != null; try { Reader reader = new BufferedReader(new FileReader("/tmp/testPerst.xml")); db.importXML(reader); reader.close(); } catch (IOException x) { System.err.println("Import failed: " + x); throw x; } db.close(); } private @NonNull Storage getStorage() { Storage db = StorageFactory.getInstance().createStorage(); db.open("test.dbs", Storage.DEFAULT_PAGE_POOL_SIZE); getRootIndex(db); return db; } private @NonNull MyRoot getRootIndex(@NonNull Storage db) { MyRoot o = (MyRoot) db.getRoot(); if(o == null) { o = new MyRoot(db); o.put(new Persistent(), "key1", "key2"); db.setRoot(o); } return o; } } The XML is: <?xml version="1.0" encoding="UTF-8"?> <database root="4100"> <testperst.MyRoot id="4100"> <rootIndex><ref id="4103"/></rootIndex> </testperst.MyRoot> <org.garret.perst.impl.BtreeCompoundIndex id="4103" unique="1" type0="String" type1="String"> <ref id="4097" key0="key1" key1="key2"/> </org.garret.perst.impl.BtreeCompoundIndex> <org.garret.perst.Persistent id="4097"> </org.garret.perst.Persistent> </database> Regards, Vladimir