Uploaded image for project: 'Cayenne'
  1. Cayenne
  2. CAY-763

XML Deserialization fails on relationships when using a mapping file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2 branch, 2.0 branch, 3.0
    • 3.0M1
    • Core Library
    • None
    • Any

    Description

      When XMLDecoder deserializes objects using a mapping descriptor, no objects are registered with a datacontext until after all objects have been initialized. However, cayenne requires a non-null datacontext to correctly handle relationships. Hence, dataobjects using the default cayenne handling of relationships (either to-one or to-many) will be unable to deserialize objects from XML (due to null pointers).

      In the case of a collection, the getXXX method will return null, and the XMLMappingDescriptor fails to "sense" a collection.
      In the case of a to-one relationship, a NPE exception is thrown trying to set the child property of the parent object.

      The simplest way to fix this would be to make XMLMappingDescriptor DataContext-capable (ie: will register objects with a datacontext, if one is provided, as the objects are created). I've done this in a local copy of the code. I will attach a patch when I get a minute.

      Attachments

        1. cay-763.patch
          6 kB
          Robert Zeigler

        Activity

          People

            nirvdrum Kevin Menard
            ongakugainochi Robert Zeigler
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: