((ODocument) whiz.field("account")).delete();
whiz.delete();
}
public void linkedIndexedProperty() {
ODatabaseDocument db = new ODatabaseDocumentTx(database.getURL());
db.open("admin", "admin");
if (!db.getMetadata().getSchema().existsClass("TestClass")) {
OClass testClass = db.getMetadata().getSchema().createClass("TestClass");
OClass testLinkClass = db.getMetadata().getSchema().createClass("TestLinkClass");
testClass.createProperty("testLink", OType.LINK, testLinkClass).createIndex(OClass.INDEX_TYPE.NOTUNIQUE);
testClass.createProperty("name", OType.STRING).createIndex(OClass.INDEX_TYPE.UNIQUE);
testLinkClass.createProperty("testBoolean", OType.BOOLEAN);
testLinkClass.createProperty("testString", OType.STRING);
db.getMetadata().getSchema().save();
}
ODocument testClassDocument = db.newInstance("TestClass");
testClassDocument.field("name", "Test Class 1");
ODocument testLinkClassDocument = new ODocument("TestLinkClass");
testLinkClassDocument.field("testString", "Test Link Class 1");
testLinkClassDocument.field("testBoolean", true);
testClassDocument.field("testLink", testLinkClassDocument);
testClassDocument.save();
// THIS WILL THROW A java.lang.ClassCastException: com.orientechnologies.orient.core.id.ORecordId cannot be cast to
// java.lang.Boolean
List<ODocument> result = db.query(new OSQLSynchQuery<ODocument>("select from TestClass where testLink.testBoolean = true"));
Assert.assertEquals(result.size(), 1);
// THIS WILL THROW A java.lang.ClassCastException: com.orientechnologies.orient.core.id.ORecordId cannot be cast to
// java.lang.String
result = db.query(new OSQLSynchQuery<ODocument>("select from TestClass where testLink.testString = 'Test Link Class 1'"));
Assert.assertEquals(result.size(), 1);
db.close();
}