You can model such relationship as field reference to another document (using @Ref annotation): https://www.arangodb.com/docs/3.6/drivers/spring-data-reference-mapping-reference.html or as graph edge relationship (using @Relations annotation): https://www.arangodb.com/docs/3.6/drivers/spring-data-reference-mapping-relations.html
Here you can find usage examples: https://github.com/arangodb/spring-data/blob/b0197ded471ae4b2b45cc5347e16accf0d08c1be/src/test/java/com/arangodb/springframework/core/mapping/RelationsMappingTest.java#L53-L73 https://github.com/arangodb/spring-data/blob/7903c19b56adef1fcc39c8ff2c2100445f5bda21/src/test/java/com/arangodb/springframework/core/mapping/RefMappingTest.java#L56-L67 In both cases you have to save entities one by one, since ArangoDB Spring Data does make use of Stream Transactions yet. On Wednesday, 1 April 2020 22:58:54 UTC+2, Rob Gratz wrote: > > > I am trying to see if Arango DB can be used in a Spring Data application. > I know there is a Spring Data implementation for Arango but am having > trouble getting it to work as I think it should. I guess my question is, > if I have a parent object that has a child object as a field, is there any > annotation on the child object field that will make the parent save off a > relationship with the child? > > > class Parent { > private Child child; > Parent(Child child) > { > this.child = child; > } > } > > class Child { > private String name; > Child(String name) > { > this.name = name; > } > } > > > Is there a way that this command will create both the child and the parent > and the relationship/edge between them? > repo.save(new Parent(new Child("sam")); > > If the answer is that I have to save them all independently then I don't > believe this is a very good implementation for Spring Data. To me I > shouldn't have to have 3 different repos and make 3 different calls to save > a simple object graph. > > Any help would be gladly appreciated. > > -- You received this message because you are subscribed to the Google Groups "ArangoDB" group. To unsubscribe from this group and stop receiving emails from it, send an email to arangodb+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/arangodb/0605c2ec-6ea4-4565-9a94-2c0efbcccfac%40googlegroups.com.