XML Mapping File

From: Ted Moens (tmoen..elus.net)
Date: Wed Dec 12 2007 - 06:21:07 EST

  • Next message: Carmen Grantham: "2.0.4 NullPointerException in ExpressionFactory.likeExp"

    Greetings:

    I'm using Cayenne 3.0M2 on Vista.

    I am trying to create some XML to represent data in my database. I was
    unable to find clear documentation on the file format and usage for the
    XML Mapping File that guides the generation, though this page is
    tantalizing:

    http://cwiki.apache.org/confluence/display/CAY/XML+Mapping+File
    XML Mapping File - Apache Cayenne - Apache Software Foundation

    and the example files in this issue were helpful too:

    https://issues.apache.org/cayenne/browse/CAY-597
    [#CAY-597] XML Encoder with Mapping outputs incorrect XML - Apache
    Cayenne Issue Tracker

    In any case, I have pretty much figured out how to do what I want with
    the mapping file and I find it *extremely* easy and straight forward.
    Here comes the BUT....

    1) if one does not define the properties of an object explicitly in the
    Mapping file, Cayenne does its best and outputs all the scalar
    properties or an object in the XML Example:

    <lastUpdate type="java.util.Date">2007-12-10 09:34:00 PST</lastUpdate>

    If one does define the same property using the <entity> ... <property
    .../> ... </entity> tags, Cayenne will output it like so:

    <lastUpdate>2007-12-10 09:34:00 PST</lastUpdate>

    So, in one case type information is lost and in the other it is
    maintained. Is there a reason for this? Is there a way to get Cayenne
    to output the type information always?

    2) collections/lists - is there any way to use the mapping file to cause
    the XML to group a set of recurring elements? That is, I would like:
    ...
    <country>
    ...
            <cities>
                    <city .../>
                    <city .../>
                    ...
                    <city ...>
            </cities>
    ...
    </country>
    ...

    Rather than what I am getting, namely:
    ...
    <country>
    ...
            <city .../>
            <city .../>
            ...
            <city ...>
    ...
    </country>
    ...

    Kind regards,

    Ted Moens



    This archive was generated by hypermail 2.0.0 : Wed Dec 12 2007 - 06:21:45 EST