// OPEN THE DATABASE ODatabaseDocumentTx db = new ODatabaseDocumentTx("remote:localhost/petshop").open("admin", "admin"); // CREATE A NEW DOCUMENT AND FILL IT ODocument doc = new ODocument("Person"); doc.field( "name", "Luke" ); doc.field( "surname", "Skywalker" ); doc.field( "city", new ODocument("City" ).field("name","Rome").field("country", "Italy") ); // SAVE THE DOCUMENT doc.save(); // QUERY THE DOCUMENT List<ODocument> result = database.query( new OSQLSynchQuery>("select * from person where city.name = 'Rome'")).execute(); // PRINT THE RESULT SET for( ODocument d : result ){ System.out.println("Person: " + d.field( "name" ) + d.field( "surname" )); } db.close();