strange return from a many to many relationship

From: moraru_et..pymac.com
Date: Mon Jan 17 2005 - 16:15:58 EST

  • Next message: Andrus Adamchik: "ProcedureQuery Hint"

    ('binary' encoding is not supported, stored as-is) i made a simple cayenne project with only 2 entities with many - to - many
    relationship between: Om - Adresa n:m. i created 3 tables and i used flattened
    relation for mapping. the db is mysql 4.1 and cayenne is v1.1. the cayenne
    project files are atached

    i have 2 jsp : a.jspo inserts values and b.jsp retrieve some

    the strange part is i'm inserting 2 values for each entity but i retrieve 3
    (where 2 are identical!!).

    Example: for the Adresa with id =223 the Om returned are: 225;225;226 !!

    a.jsp
    -----------

    <..page language="java"
    import="java.util.*,org.objectstyle.cayenne.*,ro.cd.*,org.objectstyle.cayenne.access.*"
    %>
    <%
    DataContext context = DataContext.getThreadDataContext();
    Om o = (Om)context.createAndRegisterNewObject(Om.class);
    o.setNume("gigel");
     
    Om o1 = (Om)context.createAndRegisterNewObject(Om.class);
    o1.setNume("gigel");
           
    Adresa a = (Adresa)context.createAndRegisterNewObject(Adresa.class);
    a.setAdresa("iuliu maniu");

    Adresa a1 = (Adresa)context.createAndRegisterNewObject(Adresa.class);
    a1.setAdresa("iuliu maniu");

    o.addToADD_ARRAY(a);
    o.addToADD_ARRAY(a1);

    a.addToOM_ARRAY(o);
    a.addToOM_ARRAY(o1);

      context.commitChanges();

    %>

    b.jsp
    --------------

    <..page language="java"
    import="java.util.*,org.objectstyle.cayenne.*,ro.cd.*,org.objectstyle.cayenne.access.*"
    %>

    <%

    DataContext context = DataContext.getThreadDataContext();

    Adresa ss = (Adresa)DataObjectUtils.objectForPK(context,
     Adresa.class, Integer.parseInt("223"));
      List l = ss.getOM_ARRAY();
      
      Iterator it = l.iterator();
      while(it.hasNext()){
              Om os = (Om)it.next();
              System.out.println(DataObjectUtils.intPKForObject(os));
      }
      System.out.println("ddddd ddddd " + ss.getOM_ARRAY().size());
    %>









    This archive was generated by hypermail 2.0.0 : Mon Jan 17 2005 - 16:16:09 EST