我正在尝试从rhino script访问orientDB。我收到了错误
js: Can't find method com.orientechnologies.orient.core.db.ODatabaseRecordWrapperAbstract.query(com.orientechnologies.orient.core.sql.query.OSQLSynchQuery)
当我执行以下代码时:
var System = java.lang.System
var OSQLSynchQuery = Packages.com.orientechnologies.orient.core.sql.query.OSQLSynchQuery
var ODatabaseDocumentTx = Packages.com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx
var ODocument = Packages.com.orientechnologies.orient.core.record.impl.ODocument
var File = java.io.File
var user_home = System.getProperty( "user.home" )
var db_path = user_home + "/.testdb"
var db_url = "local:" + db_path + File.separator + "db"
if( ! new File( db_path ).exists() ) {
new File( db_path ).mkdirs()
new ODatabaseDocumentTx( db_url ).create()
}
var db = new ODatabaseDocumentTx( db_url ).open( "admin", "admin" )
db.getStorage().getConfiguration().txSegment.setSynchRecord( true )
print( 'Select From TestObj' )
if( db.getMetadata().getSchema().getClass( 'TestObj' ) != null ) {
var result = db.query( new OSQLSynchQuery( "select * from TestObj" ) )
print( "# of Entries: " + result.size() )
}
db.close()
我正在访问已创建并已填充的数据库。选择适用于控制台。
我检查了javadoc,ODatabaseRecordWrapperAbstract.query方法接受了OSQLSynchQuery实现的OQuery。
答案 0 :(得分:2)
query method正在使用varargs。犀牛可能无法处理。尝试传入一个额外的空Object数组:
var result = db.query(
new OSQLSynchQuery( "select * from TestObj" ), [] )