Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 #10217

Open
adepase opened this issue Apr 15, 2024 · 4 comments
Labels
Milestone

Comments

@adepase
Copy link

adepase commented Apr 15, 2024

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)

image

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

@tglman tglman added the bug label May 18, 2024
@tglman tglman added this to the 3.2.x milestone May 18, 2024
@tglman
Copy link
Member

tglman commented Jul 15, 2024

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

@adepase
Copy link
Author

adepase commented Oct 30, 2024

Thank you, but I don't understand: what should I use instead of OSQLSynchQuery? Where can I find the documentation about the new query engine (both in script and in Java). About the API I'm using, I don't understand what you mean exactly: I wrote the gradle imports and all the code involved in the issue description, what other information are you asking for?

@tglman
Copy link
Member

tglman commented Nov 1, 2024

Hi,

In the code you posted I can see:

			OSQLSynchQuery<OrientVertex> query = new OSQLSynchQuery<OrientVertex>(queryString);
			OCommandRequest command= graph.command(query);
			Iterable<OrientVertex>resultIterable = command.execute(params);

Which already use OSQLSynchQuery what I'm saying is trying to migrate do another API to execute the query, that on the graph is called executeSql or querySql.

So you should NOT use OSQLSyncQuery but the other API that use a String as paramenter

@tglman
Copy link
Member

tglman commented Nov 1, 2024

Acutally are you using the legacy OrientDB Graph APIs ? the one with the package "com.tinkerpop.blueprints.impls.orient" ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants