Menu

Map class field to a flat representation

Help
Anonymous
2012-09-27
2013-05-02
  • Anonymous

    Anonymous - 2012-09-27

    Hello,

    I've been googling and trying different approaches for that but so far couldn't find a simple solution…
    Problem is as follow:

    class A {
     String test;
     B test2;
    }
    class B {
     String test3;
     String test4;
    }
    class C {
     String test;
     String test3;
     String test4;
    }
    

    Now I would like to map all of the fields from A (including B) to a flat representation in C.
    Is it possible to do using just configuration? The problem is that class B is used in many places and I don't to write a mapping like this for each of them:

    <mapping>
            <class-a>A</class-a>
            <class-b>C</class-b>
            <field>
                <a>test2.test3</a>
                <b>test3</b>
            </field>
            <field>
                <a>test2.test4</a>
                <b>test4</b>
            </field>
        </mapping>
    

    Would appreciate a solution for that :)

     
  • Anonymous

    Anonymous - 2012-09-27

    Well ideally it could look like this:

        <mapping>
            <class-a>A</class-a>
            <class-b>C,D,E</class-b>
            <field>
                <a>test2</a>
            </field>
        </mapping>
    

    Where D and E are different classes but consisting same fields as B + some additional

     

Log in to post a comment.