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 <[email protected]> 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 [email protected]. > 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 [email protected]. For more options, visit https://groups.google.com/d/optout.
