I have the following code. And problem is that I was unable to find any documentation on how to extract/cast OResult to my java type and get pojo.
OrientDBObject orientDBObject;
try (ODatabaseObject databaseObjectInner = orientDBObject.open(dbName, username, password)) {
specFromDB = getEntitySpecInt3(databaseObjectInner, objectId, rid);
try (OResultSet resultSet = databaseObject.query(queryByRid)) {
if (!resultSet.hasNext()) {
return null;
}
Object specObj = resultSet.next();
// how to cast properly?
return (EntitySpec) specObj;
}
}
How to cast or get object from OResult?
Thanks.
In OrientDB v 3.0 you have two ways to do it.
The easy one: just use
db.objectQuery()instead ofdb.query(), it just returns POJOs.The second way is to extract the OIdentifiable from the OResult and then use
db.getUserObjectByRecord()to convert it to a POJO: