Re: Weird behavior (M5)

From: Nick Stuart (nicholas.stuar..mail.com)
Date: Mon Aug 22 2005 - 08:26:06 EDT

  • Next message: Neil Pierson: "Prefetch SQL drops part of join"

    Hi Andrus, took some time and stepped through the code and found out
    exactly what is going on, still dont know why, but here is what is
    happening.

    In my page create method I pass a template object in. The template has
    a toManyList for blocks. When the method starts this toManyList has
    the list "addedToUnresolved" and it has the right number (2) of
    objects in it. The wierd part is, as soon as I run this line:
    List tBlocks = template.getBlocks();
    the objects move from "addedToUnresolved" to "objectList" but now I
    have 4 of them. :(

    It gets stranger, in that if I run this line:
    assertEquals(2, template.getBlocks().size());
    Then the objects go from "addedToUnresolved" to "objectList" and I end
    up with the right amount of objects.

    Hope this helps you out, and explains my situation a little better. If
    you need any more info let me know.

    -Nick

    On 8/20/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
    > Dunno, everything seems fine to me. Again, my advise would be to use
    > Eclipse debugger. Instead of trying to guess you will see exactly
    > what's going on.
    >
    > Andrus
    >
    >
    > On Aug 20, 2005, at 3:08 AM, Nick Stuart wrote:
    >
    > > Sorry, knew I should of posted more. All i do to add the blocks to
    > > both a page and a template is say something like:
    > >
    > > block.setPage(page); //or template (whatever may be the case)
    > >
    > > in my pf/create() method I simply have a loop that calls for each
    > > block ion the template :
    > >
    > > List list = template.getBlocks();
    > >
    > > it loops over the above list and adds new page blocks to a page.
    > >
    > > Doing a list.size() here is showing me 4 (where it should only be 2!)
    > > and so adds 4 blocks when there should only be 2. So I am not sure
    > > whats going on. I'm not doing anything fancy, and as I said,
    > > everything is generated in the database fine, except the page has
    > > duplicate entries added to it because something is acting screwy here.
    > > I used the modeler to generate the classes/schema with no problems or
    > > errors there.
    > >
    > > Thanks for the help!
    > > -Nick
    > >
    > >
    > >
    > > On 8/19/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
    > >
    > >> No idea what's wrong, as the code example that you posted uses your
    > >> own methods to setup relationships. Also it is not clear whether
    > >> template.getBlocks() and page.getBlocks() are generated methods for
    > >> mapped relationships or methods with custom logic (?)
    > >>
    > >> I guess the easiest way to detect what's wrong is to run this block
    > >> of code in debugger and step through the suspect methods.
    > >>
    > >> Andrus
    > >>
    > >>
    > >> On Aug 19, 2005, at 8:52 PM, Nick Stuart wrote:
    > >>
    > >>
    > >>> Hi all, playing around with Release M5 and am having a weird problem
    > >>> with some toMany relationships.
    > >>>
    > >>> Here's the test code:
    > >>> template = tf.create("TestPageTemplate", false, ctx);
    > >>> assertNotNull(template);
    > >>> tf.addBlock(template, "Block1PageCreate", ctx);
    > >>> tf.addBlock(template, "Block2PageCreate", ctx);
    > >>> //assertEquals(2, template.getBlocks().size());
    > >>>
    > >>> CmsPage page = pf.create(template, name, description, ctx);
    > >>> assertNotNull(page);
    > >>> assertEquals(name, page.getName());
    > >>> assertEquals(description, page.getDescription());
    > >>> assertEquals(template, page.getTemplate());
    > >>> System.out.println("****** " + template.getBlocks().size
    > >>> () + "
    > >>> -- " + page.getBlocks().size());
    > >>>
    > >>> Now if I leave the first assertEquals(2,...) commented out I get a
    > >>> print out of ******* 4 --- 4. Hmmm...interesting. BUT if I
    > >>> uncomment
    > >>> the first assert I get a print out showing 2 -- 2 as I would
    > >>> expected!
    > >>> Whats up with that? The database only shows that the 2 template
    > >>> blocks
    > >>> have been created, but 4 show up in the list, and 4 show up in the
    > >>> page blocks! Doh!
    > >>>
    > >>> I believe I'm adding stuff correctly to the ctx/objects/whatever as
    > >>> its all showing up and acts correctly with that assert
    > >>> uncommented....any ideas?
    > >>>
    > >>> -Nick
    > >>>
    > >>>
    > >>>
    > >>
    > >>
    > >>
    > >
    > >
    >
    >



    This archive was generated by hypermail 2.0.0 : Mon Aug 22 2005 - 08:26:09 EDT