Skip to content

Mapping a flat source to a nested destination not working #89

@rajalingams

Description

@rajalingams

I am trying to convert the flat source to the nested destination structure using a single jmapper instance with an xml configuration.

My source class:

class Source {
    String name;
    Integer age;
    String city;
}

My destination classes:

class Destination {
    String fullName;
    PersonalInfo personalInfo;
}
class PersonalInfo {
    Integer age;
    String location;
}

XML configuration:

<jmapper>
    <class name="Destination">
        <attribute name="fullName">
            <value name="name"/>
        </attribute>
        <attribute name="personalInfo">
            <value name="${}"/>
        </attribute>
    </class>
    <class name="PersonalInfo">
        <attribute name="age">
            <value name="age"/>
        </attribute>
        <attribute name="location">
            <value name="city"/>
        </attribute>
    </class>
</jmapper>

"${}" is not working. I know that it works if the source also has an encapsulated class and it can be passed in. Is there a way to pass the original instance as a whole to personalInfo?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions