Re: toMany relationship not fetched

From: Marcin Skladaniec (marci..sh.com.au)
Date: Wed Apr 12 2006 - 23:39:14 EDT

  • Next message: Robert Zeigler: "Re: toMany relationship not fetched"

    Hello everyone !

    Andrus, thank you for fixing that bug so quickly !

    I got another problem, it may be related to previous thats why I post
    it here.

    It does not happen always, I tried to create a separate project to
    reproduce it, but I couldn't.

    This is the code which reproduces problem in my application:

                                    CayenneContext context = ContextManager.getNewDedicatedContext();
                                    List students = context.performQuery(new SelectQuery
    (Student.class));
                                    for (int i=0 ; i<students.size();i++) {
                                            Student student = (Student)students.get(i);

                                            //this works ...
                                            logger.info(i+ ") students count = " +student.getLanguage
    ().getStudents().size());
                                            
                                            //this don't work
                                            logger.info(i+ ") language name = " +student.getLanguage
    ().getName());
                                    }
                                    
                                    CayenneContext context2 = ContextManager.getNewDedicatedContext();
                                    List languages = context2.performQuery(new SelectQuery
    (Language.class));
                                    for (int i=0 ; i< languages.size();i++) {
                                            Language language = (Language)languages.get(i);
                                            if (language.getStudents().size() > 0) {

                                                    logger.info(i+ ") language name = " +language.getName());
                                                    logger.info(i+ ") students count = " +language.getStudents
    ().size());

                                                    for (int j =0;j<language.getStudents().size();j++) {
                                                            Student student = ((Student)language.getStudents().get(j));
                                                            logger.info("\t"+j+ ") student name = " +student.getFullName());
                                                            logger.info("\t"+j+ ") student language = "
    +student.getLanguage().getName());
                                                            
                                                    }
                                            }
                                    }

    On output I'm getting :

       - 0) students count = 1
       - 0) language name = null
       - 1) students count = 1
       - 1) language name = null
       - 2) students count = 1
       - 2) language name = null

      - 8) language name = Galic
      - 8) students count = 1
              - 0) student name = test test
              - 0) student language = Galic
      - 1287) language name = Guatamalan
      - 1287) students count = 1
              - 0) student name = test2 test2
              - 0) student language = Guatamalan
      - 1509) language name = English
      - 1509) students count = 1
              - 0) student name = test3 test3
              - 0) student language = English

    It looks like sometimes the object is not "faulted" correctly. I
    can't see when and why ...

    Marcin

    On 11/04/2006, at 5:35 PM, Andrus Adamchik wrote:

    > Ok, now I got it. This is a bug - RelationshipQuery was incorrectly
    > intercepted by the client CayenneContext. I opened a bug report:
    >
    > http://objectstyle.org/jira/browse/CAY-500
    >
    > and actually already checked in the fix, so it should be available
    > in 04/11 nightly build.
    >
    > Thanks
    > Andrus
    >
    >
    > On Apr 11, 2006, at 4:58 AM, Marcin Skladaniec wrote:
    >
    >

    -------------------------->
    ish
    http://www.ish.com.au
    Level 1, 30 Wilson Street Newtown 2042 Australia
    phone +61 2 9550 5001 fax +61 2 9550 4001



    This archive was generated by hypermail 2.0.0 : Wed Apr 12 2006 - 23:39:40 EDT