toMany relationship not fetched

From: Marcin Skladaniec (marci..sh.com.au)
Date: Fri Mar 17 2006 - 01:56:19 EST

  • Next message: Tore Halset: "Re: toMany relationship not fetched"

    Hi
    I'm using M11. I found that objects on the "one" side of many to one
    relationships are not fetched correctly. Could someone confirm ? I
    have a feeling that there is something wrong with my project ...

            SelectQuery query1 = new SelectQuery(CCompany.class,
    ExpressionFactory.matchExp(CCompany.NAME_PROPERTY, "test company"));
            SelectQuery query2 = new SelectQuery(CPerson.class,
    ExpressionFactory.matchExp(CPerson.NAME_PROPERTY, "test person"));
            
            List list = context1.performQuery(query1);
                if (list.size() == 1) {
                    CCompany company = (CCompany)list.get(0);
                    
                    logger.info("got company : " + company);

                    List list2 = context.performQuery(query2);
                    
                    if (list2.size() > 0) {
                        CPerson person = (CPerson)list2.get(0);
                        logger.info("got person : " + person);
                        person.setCompany(company);
                    
                    }
                }
            
            context.commitChanges();
                    
                    List list2 = context2.performQuery(query2);
                    
                    if (list2.size() > 0) {
                        CPerson person = (CPerson)list2.get(0);
                        logger.info("got person : " + person);
                        logger.info("with company : " + person.getCompany()); // null
    company fetched. (No sql is executed either)
                    }

    but reverse relationship works !

                list = context3.performQuery(query1);
                if (list.size() == 1) {
                    CCompany lang = (CCompany)list.get(0);
                    logger.info("got company " + company);
                    
                    for (int i =0;i< company.people().size();i++) {
                        logger.info("CPerson "+i+" "+((CPerson)company.people().get
    (i))); //works (and this line cause sql select)
                    }
                    
                }

    Regards
    Marcin



    This archive was generated by hypermail 2.0.0 : Fri Mar 17 2006 - 01:56:22 EST