Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OrientDB error when trying to browse a class via console

I am using OrientDB in an embedded situation in Java. I am creating the database and classes in my application and inserting the data. When I go to view the data through the console, I can see the classes in the database, along with the correct number of rows in the classes. However when I try to browse the data in the class via this command browse class testData, I receive the following error

Error: com.orientechnologies.orient.core.exception.OSerializationException: Found invalid % character. Ensure it is opened and closed correctly.

I have scoured my source data and it does not contain any %. I know that OrientDB is sensitive to spacing especially around characters like ) but again the data that I have does not use the character for which there seems to be an error.

Has anyone run into this kind of error? Any ideas on how to resolve the error?

Code for creating the database

private void createNewOrientDatabase(){
    String dbPath = "plocal:./db/test";
    orientDatabase = new ODatabaseDocumentTx(dbPath).create();
}

Code for creating the classes

 public void createClasses(Table t){
    if(orientDatabase.getMetadata().getSchema().getClass(t.getName()) == null) {
        orientDatabase.getMetadata().getSchema().createClass(t.getName());
    }
 }

Code for inserting the data

public void insertData(Table table, TableSource data){
    for (String s : data){
        ODocument document = new ODocument(table.getName());
        String[] parts = s.split(",");
        for(int i = 0; i < table.getColumns().size(); ++i){
            document.field(table.getColumns().get(i).getName(),parts[i]);
        }
        document.save();
    }
}

There are multiple classes but for a give class, the data might look something like this 43840,533,1,1,3,4 just to give you an idea about what the data looks like.

As always, thanks in advance for any help!

like image 345
mfunaro Avatar asked Nov 01 '22 23:11

mfunaro


1 Answers

Found the cause of the error...

When I was parsing my source data for the column names, they were in the form integer name; and I had forgotten to strip off the ; from the name. So when I created the field in the document the name had the ; on the end and this was causing the error when trying to browse the class in OrientDB console.

like image 71
mfunaro Avatar answered Nov 15 '22 03:11

mfunaro