Proper way to get ORID

35 views
Skip to first unread message

TomekK

unread,
Dec 23, 2016, 8:41:42 AM12/23/16
to OrientDB
Hello, could you help me?

I have class with documents with link to attachments in another class. 
I need to get RIDs and some (not all) fields.

My code:
       final OSQLSynchQuery<ODocument> query = new OSQLSynchQuery<ODocument>("select @rid as id, attachmentRID, field_1, field_2  from Mail");
       for (ODocument record : resultset) {
              ORID rid = ((ODocument)record.field("id")).getIdentity();
              ORID arrachmentRid = ((ODocument)record.field("attachment")).getIdentity();
              ...
       }}

1) What's the proper way to get RID of document, or linked document?
I suppose that there is a better way, because I don't want to get all document, but only RIDs.

2) Is "select field_1, field_2, ... field_k from..." faster or require lower memory than getting all field "select * from... "?
Some of the fields stores files, and I don't want to download them from the database, when it's not necessary. Should I put them into different class and use OType.Link?




Oleksandr Gubchenko

unread,
Dec 23, 2016, 9:01:19 AM12/23/16
to OrientDB
Try
record.getIdentity();
Message has been deleted

TomekK

unread,
Dec 26, 2016, 11:25:32 AM12/26/16
to orient-...@googlegroups.com
Try
record.getIdentity();

It would give something with the minus sign. It could be record's RID if it was 'SELECT * FROM...", but I don't want get all record, but only few fields.
Reply all
Reply to author
Forward
0 new messages