After upgrading from 3.1.9 to 3.2.28 I get java.lang.ClassCastException: com.orientechnologies.orient.core.sql.executor.OResultInternal cannot be cast to com.orientechnologies.orient.core.db.record.OIdentifiable
adepase opened this issue · 4 comments
OrientDB Version: 3.2.28
Java Version:
OS: Docker OrientDB 3.2.28 Official image (https://hub.docker.com/_/orientdb/)
Expected behavior
First attempt to use 3.2.X (coming from previous OrientDB version 3.1.9, where everything worked correctly).
I hoped my queries from Java worked correctly, but I got blocking errors.
Base query: select expand(findDict(null, 'prova', null, null, null, null, null, null, 'it', null, 1000, 1, null))
Java code calling OrientDB:
private static String ALL_DICTIO = "select expand(findDict(:pid, :plemma, :pstem, :pclitic, :ptype, :psimpleType, :pexcludeType, :pconfirmed, :plang, :pplainPart, :size, :page, :orderBy))";
ArrayList<OrientVertex> pass = ograph.execQuery(ALL_DICTIO, map);
Where map contains parameters names and values and where ograh.execQuery is:
public ArrayList<OrientVertex> execQuery(String queryString,Map<String,Object> params){
ArrayList<OrientVertex> result = new ArrayList<OrientVertex>();
OrientGraph graph = orientFactory.getTx();
graph.makeActive();
try{
OSQLSynchQuery<OrientVertex> query = new OSQLSynchQuery<OrientVertex>(queryString);
OCommandRequest command= graph.command(query);
Iterable<OrientVertex>resultIterable = command.execute(params);
if (resultIterable!=null) {
for(OrientVertex v: resultIterable){
v.detach();
result.add(v);
}
}
} catch (OCommandExecutionException e) {
// exception code
} catch (Exception e){
// exception code
} finally {
graph.shutdown(); //not a shutdown, but return to the pool
}
return result;
}
findDict code is:
var query = "select from morph where";
var op = " ";
var parms = {};
// omitted code to dinamically compose the where and limit part of the query
print("query = "+query+" parms="+JSON.stringify(parms));
var pass = db.query(query,parms);
return pass;
Possible counfounding cause: I'm using this versions for Java libs:
implementation ('com.orientechnologies:spring-boot-orientdb-autoconfigure:0.14-3.1.0-SNAPSHOT'){
exclude module: 'hibernate-jpa-2.0-api'
}
implementation ('com.orientechnologies:orientdb-graphdb:3.2.29'){
exclude module: 'hibernate-jpa-2.0-api'
}
implementation ('com.orientechnologies:orientdb-object:3.2.29'){
exclude module: 'hibernate-jpa-2.0-api'
}
I tested also:
- com.orientechnologies:orientdb-graphdb:3.2.28
- and com.orientechnologies:orientdb-object:3.2.28
with the same results (exceptions).
I don't know if is there a more recent replacement for com.orientechnologies:spring-boot-orientdb-autoconfigure:0.14-3.1.0-SNAPSHOT: Is this yet good? what should I use instead? (I cannot find the repository with new versions, I tried 3.2.0 and 3.2.29 (both with and without -SNAPSHOT)
Actual behavior
Cannot execute correctly, but I get an exception (from Java: the same sql select, with the same parameters from OrientDB studio Browse tab executes correctly):
com.orientechnologies.orient.core.exception.OCommandExecutionException: Error on execution of command: sql.select expand(findDict(:pid, :plemma, :pstem, :pclitic, :ptype, :psimpleType, :pexcludeType, :pconfirmed, :plang, :pplainPart, :size, :page, :orderBy))
2024-04-15 13:58:26 DB name="mrj"
2024-04-15 13:58:26 at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.executeCommand(OAbstractPaginatedStorage.java:4218)
2024-04-15 13:58:26 at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.command(OAbstractPaginatedStorage.java:4171)
2024-04-15 13:58:26 at com.orientechnologies.orient.core.sql.query.OSQLQuery.run(OSQLQuery.java:72)
2024-04-15 13:58:26 at com.orientechnologies.orient.core.sql.query.OSQLAsynchQuery.run(OSQLAsynchQuery.java:76)
2024-04-15 13:58:26 at com.orientechnologies.orient.core.sql.query.OSQLSynchQuery.run(OSQLSynchQuery.java:84)
2024-04-15 13:58:26 at com.orientechnologies.orient.core.query.OQueryAbstract.execute(OQueryAbstract.java:34)
2024-04-15 13:58:26 at com.orientechnologies.orient.server.OConnectionBinaryExecutor.executeCommand(OConnectionBinaryExecutor.java:618)
2024-04-15 13:58:26 at com.orientechnologies.orient.client.remote.message.OCommandRequest.execute(OCommandRequest.java:102)
2024-04-15 13:58:26 at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.sessionRequest(ONetworkProtocolBinary.java:354)
2024-04-15 13:58:26 at com.orientechnologies.orient.server.network.protocol.binary.ONetworkProtocolBinary.execute(ONetworkProtocolBinary.java:238)
2024-04-15 13:58:26 at com.orientechnologies.common.thread.OSoftThread.run(OSoftThread.java:68)
2024-04-15 13:58:26 Caused by: java.lang.ClassCastException: com.orientechnologies.orient.core.sql.executor.OResultInternal cannot be cast to com.orientechnologies.orient.core.db.record.OIdentifiable
2024-04-15 13:58:26 at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.applyExpand(OCommandExecutorSQLSelect.java:2685)
2024-04-15 13:58:26 at com.orientechnologies.orient.core.sql.OCommandExecutorSQLSelect.execute(OCommandExecutorSQLSelect.java:527)
2024-04-15 13:58:26 at com.orientechnologies.orient.core.sql.OCommandExecutorSQLDelegate.execute(OCommandExecutorSQLDelegate.java:74)
2024-04-15 13:58:26 at com.orientechnologies.orient.core.storage.impl.local.OAbstractPaginatedStorage.executeCommand(OAbstractPaginatedStorage.java:4205)
2024-04-15 13:58:26 ... 10 more
2024-04-15 13:58:26
2024-04-15 13:58:26 2024-04-15 11:58:26:088 SEVER Exception `64225EFF` in storage `plocal:/orientdb/databases/mrj`: 3.2.28 (build ${buildNumber}, branch UNKNOWN) [OLocalPaginatedStorage]
Steps to reproduce
See previous Java code and images
Hi,
I think this happen because the query API in the script engine, for: var pass = db.query(query,parms);
has been switched do the new query engine that use OResult instead of documents as result.
I see in your java example you are using OSQLSynchQuery
that have been deprecated, and use the old query engine, you should be able to use the now query engine, how to do it, it may depends on the API you are using right now, that look like gremlin, is that the case ?
If you switch all your code to the new query engine this issue should go away.
Regards