I finally found out how to do this by googling and reading for hours, I
really wish this were properly documented (with code) in OrientDB's wiki :(

How I insert a linkset of referenced documents:

    val version = new ODocument("Version")
      .field("id", "1.0")
    version.save()

    val versions = new java.util.HashSet[ODocument]()
    versions.add(version)
    val package = new ODocument("Package")
      .field("id", "MyPackage")
      .field("versions", versions)
    package.save()

How I load the linkset for the parent ODocument:

    val versions =
doc.field[java.util.HashSet[ODocument]]("versions").asScala.toSeq

Best,
Arve


On Fri, Mar 21, 2014 at 9:49 AM, Arve Knudsen <[email protected]>wrote:

> Hi guys
>
> In a Scala app, I need to be able to insert documents that refer to other
> documents (i.e., not via graph edges), and to load the same documents with
> their referenced documents. I have been able to achieve this by inserting
> documents with references through SQL, and loading them back in Scala as
> ODocuments. However, I have not been able to insert the documents with
> their references to other documents from Scala. How can I successfully
> perform this task in Scala (i.e., storing ODocuments with references to
> other ODocuments and loading them back along with their references)?
>
> I've written a question on this on 
> StackOverflow<http://stackoverflow.com/questions/22492248/orientdb-how-do-i-insert-a-document-with-connections-to-multiple-other-documen/22497375>,
> which should give you a good idea of what I'm trying to do. Feel free to
> chime in there.
>
> Arve
>

-- 

--- 
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.

Reply via email to