0

我正在使用 OrientDb java document api 来查询数据库。我的示例代码是

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();

在此 dbconnection.command() 函数显示为已弃用,即使 orientdb 文档包含。我正在使用 orientdb 3.0.28

4

1 回答 1

1

您指向的文档适用于command未弃用的方法版本。

不推荐使用的命令的签名是:

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

文档中完整描述了已弃用命令的替代方案:

  • 您有两个不同的命令版本

    默认 OResultSet命令(字符串查询、映射参数)抛出 OCommandSQLParsingException、OCommandExecutionException

    默认 OResultSet命令(字符串查询、对象... args)抛出 OCommandSQLParsingException、OCommandExecutionException

  • 以及两种可选的执行方法

    默认 OResultSet执行(字符串语言、字符串脚本、映射参数)抛出 OCommandExecutionException、OCommandScriptException

    默认 OResultSet执行(String language,String script,Object... args) 抛出 OCommandExecutionException, OCommandScriptException

使用最适合您需要的一种。

于 2020-02-27T06:49:15.307 回答