Thanks Luca ... must say orientdb is just awesome !!! the example is the People / Address where People can work/live at the same Address; so the Address Id is unique for each address, while multiple People hold the same Address Id. What I want is for People to link to Address @rid (via Address Id that a person is referencing), are you saying that this is not possible via CREATE LINK?
It works fine using Keith's approach, ie. setting the address' @rid link in person's record. I'm aware that perhaps edges might be a better solution, but we're still just testing things out :) ... On Wednesday, January 7, 2015 5:29:00 AM UTC+11, Lvc@ wrote: > > The CREATE LINK command want unique key, but the value " > 2831b7f5-28ba-457d-b871-21be494f509c" is in more than 1 record in > database, so it can't create the LINK. > > Lvc@ > > > On 6 January 2015 at 18:38, Keith Freeman <8fo...@gmail.com <javascript:>> > wrote: > >> This works for me: >> import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; >> import com.orientechnologies.orient.core.record.impl.ODocument; >> >> public class O2DocumentHW >> { >> public static void main(String[] args) >> { >> long start = System.currentTimeMillis(); >> >> try (ODatabaseDocumentTx db = new >> ODatabaseDocumentTx("remote:localhost/testdb")) >> { >> db.open("admin", "admin"); >> db.begin(); >> >> try >> { >> ODocument target = new ODocument("doc").field("name", >> "target"); >> >> ODocument src1 = new ODocument("doc").field("name", >> "src1").field("shoots", target); >> ODocument src2 = new ODocument("doc").field("name", >> "src2").field("shoots", target); >> ODocument src3 = new ODocument("doc").field("name", >> "src3").field("shoots", target); >> >> target.save(); >> src1.save(); >> src2.save(); >> src3.save(); >> db.commit(); >> } >> catch (Exception ex) >> { >> try >> { >> db.rollback(); >> } >> catch (Exception ex1) >> { >> System.err.println("rollback exception! " + ex); >> } >> >> System.err.println("commit exception! " + ex); >> ex.printStackTrace(System.err); >> } >> finally >> { >> db.close(); >> } >> >> System.out.println("done in " + (System.currentTimeMillis() - >> start) + "ms"); >> } >> catch (Exception ex) >> { >> System.err.println("open exception! " + ex); >> ex.printStackTrace(System.err); >> } >> } >> } >> >> >> Then the query shows many-to-one: >> >> >> <https://lh5.googleusercontent.com/-qd7ZAb3zmoY/VKwdc9TRgeI/AAAAAAAACdc/aa6OQehdNqE/s1600/Screenshot%2Bfrom%2B2015-01-06%2B10%3A37%3A26.png> >> >> >> On Tuesday, January 6, 2015 12:41:31 AM UTC-7, spareshade wrote: >>> >>> Hello all >>> >>> I am getting and error when trying to establish many to one links >>> >>> com.orientechnologies.orient.core.exception.OCommandExecutionException: >>> Cannot create link because multiple records was found in class >>> 'LinkingClass' with value '2831b7f5-28ba-457d-b871-21be494f509c' in >>> field 'linkingToClassId' >>> >>> so I assume this is not possible. >>> >>> Any thoughts would be welcome :) >>> >> -- >> >> --- >> 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 orient-databa...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- --- 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 orient-database+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.