2.0.5
Query is correct (you can check for yourself on the GratefulDeadConcerts
database).
Op donderdag 26 maart 2015 22:36:56 UTC+1 schreef Colin:
>
> Hi,
>
> Which version of OrientDB are you using?
>
> Also, have you experimented with your desired result set using the console
> to verify your query?
>
> -Colin
>
> Orient Technologies
>
> The Company behind OrientDB
>
> On Thursday, March 26, 2015 at 4:58:38 AM UTC-5, MrFT wrote:
>>
>> I am trying to understand the JAVA API when they have sub-queries
>>
>> String query = "select name, $sungbyrecord as x_sungby from V " +
>> "let $sungby = outE()[ @class = 'sung_by' ], " +
>> "$sungbyrecord = list( (select in.name from $sungby ) ) " +
>> "where name='HEY BO DIDDLEY'";
>> ODatabaseDocumentTx databaseDocumentTx = new ODatabaseDocumentTx(
>> "remote:localhost/GratefulDeadConcerts" );
>> databaseDocumentTx.open( "admin", "admin" );
>> List<ODocument> result = databaseDocumentTx
>> .query( new OSQLSynchQuery<ODocument>( query ) );
>>
>> for ( ODocument d : result ) {
>> System.out.println( d.toString() ); *//prints #-2:0{name:HEY BO
>> DIDDLEY,x_sungby:[1]} v0*
>> System.out.println( d.toJSON() ); */*prints (doesn't matter if I add
>> "**fetchplan
>> x_sungby:1" to the query or not*
>> Mar 26, 2015 10:30:39 AM com.orientechnologies.common.log.OLogManager log
>> SEVERE: Fetching error on record #-2:0
>> java.lang.ArrayIndexOutOfBoundsException: -2
>> at
>> com.orientechnologies.orient.client.remote.OStorageRemote.getPhysicalClusterNameById(OStorageRemote.java:1319)
>> at
>> com.orientechnologies.orient.client.remote.OStorageRemoteThread.getPhysicalClusterNameById(OStorageRemoteThread.java:526)
>> at
>> com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.executeReadRecord(ODatabaseDocumentTx.java:1605)
>> at
>> com.orientechnologies.orient.core.tx.OTransactionNoTx.loadRecord(OTransactionNoTx.java:80)
>> at
>> com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:1424)
>> at
>> com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx.load(ODatabaseDocumentTx.java:117)
>> at
>> com.orientechnologies.orient.core.id.ORecordId.getRecord(ORecordId.java:313)
>> at
>> com.orientechnologies.orient.core.fetch.OFetchHelper.fetchCollection(OFetchHelper.java:491)
>> at
>> com.orientechnologies.orient.core.fetch.OFetchHelper.fetch(OFetchHelper.java:372)
>> at
>> com.orientechnologies.orient.core.fetch.OFetchHelper.processRecord(OFetchHelper.java:311)
>> at
>> com.orientechnologies.orient.core.fetch.OFetchHelper.fetch(OFetchHelper.java:72)
>> at
>> com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerJSON.toString(ORecordSerializerJSON.java:337)
>> at
>> com.orientechnologies.orient.core.serialization.serializer.record.string.ORecordSerializerStringAbstract.toString(ORecordSerializerStringAbstract.java:665)
>> at
>> com.orientechnologies.orient.core.record.ORecordAbstract.toJSON(ORecordAbstract.java:192)
>> at
>> com.orientechnologies.orient.core.record.ORecordAbstract.toJSON(ORecordAbstract.java:188)
>> at ft.orientdb.test.Test01.testQuery(Test01.java:681)
>> at ft.orientdb.test.Test01.main(Test01.java:100)
>>
>> *{"@type":"d","@rid":"#-2:0","@version":0,"name":"HEY BO
>> DIDDLEY","x_sungby":[]}*
>> **/*
>> }
>>
>> When trying the Async query
>>
>> databaseDocumentTx.query( new OSQLAsynchQuery<ODocument>( query, new
>> OCommandResultListener() {
>> List<ODocument> result = new ArrayList<ODocument>();
>> @Override
>> public boolean result(Object arg0) {
>> System.out.println( "Async result: " + ((ODocument)arg0).toString() );
>> result.add( (ODocument)arg0 );
>> return false;
>> }
>> @Override
>> public void end() {
>> System.out.println( "Async result finished... " + result.size() + "
>> record" );
>> }
>> } ) );
>>
>> it only returns Async result: #-2:0{name:HEY BO DIDDLEY,x_sungby:[1]} v0
>> regardless if I add *fetchplan x_sungby:1* to the query or not.
>> toJSON shows the same exception as in the SYNCH version.
>>
>> *So how should I do it to also fetch the records pointed to in the
>> subquery be done using the java API? How can I make toJSON work?*
>>
>>
>>
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.