Frage

i habe a question concerning Dozer Bean Mapping. I have the follwing xml configuration parts (i don´t understand some of this facts):

<mapping>
    <class-a>
        entity.template.TemplateEntity
    </class-a>
    <class-b>dto.template.TemplateDto
    </class-b>
    <field>
        <a set-method="setLang" get-method="getLang">lang</a>
        <b set-method="setLang" get-method="getLang">lang</b>
        <a-hint>entity.template.TemplateLanguageEntity</a-hint>
        <b-hint>dto.template.TemplateLanguageDto</b-hint>
    </field>
</mapping>

What is the concret meaning of "set-method="setLang" get-method="getLang""?

What does the Dozer Bean Mapper do in this part? There is no other configuration, which describes, how to two collection should be mapped?

<a-hint>entity.template.TemplateLanguageEntity</a-hint>
<b-hint>dto.template.TemplateLanguageDto</b-hint>

Does the Dozer Mapper map all fields automatically, which are founded by them if no configuration was set?

Thanks for helping !

Greetz Marwief

War es hilfreich?

Lösung

  • What is the concret meaning of "set-method="setLang" get-method="getLang""?

Beans that might have unorthodox getter and setter methods, Dozer support user specified setter and getter methods.To make a bi-directional mapping in this case, look at the following example below.

The source field in element A specifies a custom setter method and getter method using attributes.

<field>
  <a set-method="placeValue" get-method="buildValue">value</a>
  <b>value</b> 
</field>
  • What does the Dozer Bean Mapper do in this part? There is no other configuration, which describes, how to two collection should be mapped?

Understand the Custom set() and get() methods dozer documentation.

Lets take for example if we are mapping a String to an ArrayList by calling the addIntegerToList() method. Note that this is defined as a one-way field type since we can not map an ArrayList to a String.

<!-- we can not map a ArrayList to a String, 
         hence the one-way mapping -->
    <field type="one-way">         
      <a>integerStr</a>
      <b set-method="addIntegerToList">integerList</b>
    </field>
  • Does the Dozer Mapper map all fields automatically, which are founded by them if no configuration was set?

Yes, Dozer Mapper maps all the fields automatically from class-A to class-B iff both the field names are same.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top