Search code examples
javaorientdborientdb3.0

Alternative for deprecated command() function in orientDB


I'm using OrientDb java document api to query the database.My sample code is

OrientDB orientDB = new OrientDB("remote:localhost",OrientDBConfig.defaultConfig());
ODatabaseDocument dbConnection = orientDB.open("configurationDatabase","root", "root");
List<ODocument> date = dbConnection.command(new OCommandSQL("select date from Trial")).execute();

In this the dbconnection.command() function is displayed as deprecated , even though the orientdb documentation contains this . I'm Using orientdb 3.0.28


Solution

  • The documentation you are pointing at is for a version of the commandmethod that is not deprecated.

    The signature of the deprecated command is:

    @Deprecated
    <RET extends OCommandRequest> RET command(OCommandRequest iCommand)
    

    Alternatives to the deprecated command are fully described in the doc:

    • You have two different command versions

      default OResultSet command(String query,Map args) throws OCommandSQLParsingException, OCommandExecutionException

      default OResultSet command(String query, Object... args) throws OCommandSQLParsingException, OCommandExecutionException

    • And two alternative execute methods

      default OResultSet execute(String language, String script, Map args) throws OCommandExecutionException, OCommandScriptException

      default OResultSet execute(String language,String script,Object... args) throws OCommandExecutionException, OCommandScriptException

    Use the one that best suits your need.