Menu

Retriving oneToMany problem

Anonymous
2004-09-05
2004-09-10
  • Anonymous

    Anonymous - 2004-09-05

    Hi Richard,

    I'm having a problem retriving a oneToMany association.

    The problem is that after I retrive a oneToMany association and I try to delete an object from the collection I'm getting an exception stating that the list.Rmove failed because the object does not exist in the collection.

    The code that I'm performing is:
    p = o.Parent
    p.Col.Remove(o)

    where p is the parent in the association and o is the child in the association.

    I'm reading the association using the getAll(true) function. And, retrieveAutomatic = true for both parent and child.

    Furthermore, I've checked o.Parent against the parent object from the collection returned by the getAll(true) function and they differ.
    They have the same OIDValue but the attributes are not set for the object o.Parent.

    Any idea how to solve the problem?

    Dan

     
    • Richard Banks

      Richard Banks - 2004-09-06

      Hi Dan,

      That's a bit strange - I've done some testing to try and duplicate the problem and I can't get it to happen.  I assume you don't have any wierd code in the Parent property.

      Before you do the GetAll call can you try retrieving a single p object and see if the parent property gets set correctly?  Maybe there's something else happening that's causing the problem.

      - Richard.

       
    • Anonymous

      Anonymous - 2004-09-06

      Hi Richard,

      I don't have any wierd code in the parent property.

      I tried retrieving a single parent object and it works ok. I'm able to delete child objects without getting exceptions.

      This is very strange.

      I'll check the difference between the two pieces of code.

      Dan

       
    • Anonymous

      Anonymous - 2004-09-06

      Hi Richard,

      I found the problem.
      In the function getAll() I set the property ReturnFullObjects to true and it worked.

      My question is way is this way? Is important to retrive only proxy objects?

      Dan.

       
    • Anonymous

      Anonymous - 2004-09-06

      Hi Richard,

      After I did the modification I checked to see how does it affect the outcome of objects. And I found out something strange.

      If ReturnFullObjects is set to true then all oneToMany associations are retrieved correctly. But, all oneToOne associations are not retrieved correctly.
      But, if ReturnFullObjects is set to false then all oneToMany associations are not retrieved correctly. But, all oneToOne associations are retrieved correctly.

      I read the comments for CCursor.loadObject()  and I didn't understand them.
      Could you please explain it in more detail?

      Dan.

       
    • Richard Banks

      Richard Banks - 2004-09-07

      Hi Dan

      That's some strange behaviour!  You'd think that whoever wrote that code would know how to test it properly!!

      I've committed some changes to CVS that should fix the problem.  I've done testing locally and everything looks OK (for both 1-1 and 1-N associations).

      The code for loadObject effectively has two parts, one for loading from a MultiRetrieveCriteria and one for loading from a noraml RetrieveCriteria.

      loadObject should always return an instantiated object (with or without associations) as opposed to loadProxy which only returns proxied attributes.

      Since we need to return a full object, if the criteria only contains proxies, we must populate the object from the proxy details and then do a proper retrieve() call (which will also get associations).
      If the criteria contains full objects then we can just populate the object based on the data in the recordset and go from there - no associations are loaded.

      - Richard.

       
    • Anonymous

      Anonymous - 2004-09-07

      Hi Richard,

      I've downloaded the code from the CVS and checked it. But, I'm sorry to say it didn't help.

      I notice that objects that participate in a oneToMany associations looks like they are just read from the database.
      I mean, all attributes that are value types are instantiated, also all the fields that holds OIDs, for associations, are instantiated too. But, the attributes that should hold the associated objects are not instantiated. As if, their state is not updated although the object in the cache is updated.

      I tried to add an event to the cache and register all objects to be updated when the object in the cache is updated, but t didn't work.

      By the way, I notice the assemblyPath XML attribute is deleted from the code that handles the XML file. Why?

      Dan.

       
    • Richard Banks

      Richard Banks - 2004-09-07

      Hi Dan,

      I'm trying to figure out how you are getting a problem.  All the getAll(true) tests I have done have worked perfectly.  I've even tried with your 122 test app from the other day and it works OK in that as well.

      If you could isolate it a little further it might give me a better idea as to where things are going wrong.

      For the AssemblyPath removal:

      Have a look at this thread https://sourceforge.net/forum/forum.php?thread_id=1137020&forum_id=208150
      Basically it comes down to the way .NET handles object loading.  The same object instantiated from an assemblies in a different locations are seen a different objects and will cause type mismatches, so I needed to fix it.

      Removing the assembly path also makes the XML file more portable.

      - Richard.

       
    • Anonymous

      Anonymous - 2004-09-08

      Hi Richard,

      I've managed to reproduce the problem.

      I've posted a bug report.

      Dan.

       
      • Richard Banks

        Richard Banks - 2004-09-08

        Hi Dan,

        Excellent - thanks.  I'll look into it first thing tomorrow (Australian time).

         
        • Richard Banks

          Richard Banks - 2004-09-08

          Never mind waiting until morning...

          I've found it and fixed it.  Grab the latest version from CVS as soon as it updates and you'll be OK.

          I'll explain the issue in the bug report.

          - Richard.

           
    • Anonymous

      Anonymous - 2004-09-10

      Hi Richard,

      I've downloaded the latest CVS version.
      And, I notice that the test program that I sent you works. But, the application I'm working on is not working.

      After a short check I found the problem.
      In retreivePriveObject function I replaced all calls to retrivePrivateObject to retrieveObject and It works. This way if you have a deep tree of oneToMany all object will get the isLoading flag set to true correctly.

      I have some more updates to send you. But, I'm starting my vacation and I'll be back a week from Sunday. I'll fix some more problems with the inheritance and I'll prepare a patch and I'll post it.

      Dan

       
      • Richard Banks

        Richard Banks - 2004-09-10

        Hi Dan,

        Thanks.  I also noticed a few other problems as well.

        I've committed some changes to CVS so when you get back and put the patch together, you might want to get the latest updates from CVS first.

        P.S. Thanks for the feedback on the site

        - Richard.

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.