Menu

Cache

2005-05-11
2013-03-07
  • Nobody/Anonymous

    I have a following structure:

    A oneToMany B and B oneToOne A.

    Class A has a collection of B ("Items")

    a.items.count  ' debug (9)
    now
    a.items.add(otherObjectB)
    a.items.count 'debug (10)

    now
    otherObjectB.a.items.count ' Debug 10
    ...
    commit of transaction

    it is correct, but

    if I execute

    OtherObjectB.find(b)
    OtherObjectB.items.count ' Debug is  9 and not 10

    what happen, I think that in the cache exist 2 object OtherObjectB

     
    • Nobody/Anonymous

      if i execute clear cache, then it is correct and i have 10

       
    • Richard Banks

      Richard Banks - 2005-05-12

      My guess is that you have SaveAutomatic="false" on the one-to-one associations and you are not explicity saving object a.

      When you call OtherObjectB.find(b) it processes the one-to-one association to load the a object.  Because a is in the cache object b will reference the cached copy of A.  Since you didn't save A, the cache hasn't been updated and the A object (in the cache) will still be in it's initial state.

      Clearing the cache forces the retrieve to disk, and since obj B has a reference to A in the table, the a will load with all 10 b objects.

       

Log in to post a comment.