Announcement Announcement Module
No announcement yet.
Automatic Data Transfer Object (DTO) Creation Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Automatic Data Transfer Object (DTO) Creation

    I've decided to use DTOs to transfer my data to the view layer. My data is stored in persisted domain objects with bean style getters. I'd like to convert the data to a map of property value pairs (and later XML). I'd also like to recurse a specified depth into any referenced objects.

    Before I reinvent the wheel is there anythings that does this for me, i.e. a method like:

    Obect myBean = getBean();
    Map<String,Object> model = FooBar.convert(myBean);

    Where the Object is either a String value or a reference to another map or list.

    I get the feeling that Spring or Apache commons provides something like this but I haven't quite found it yet.

  • #2
    If you need to go deep, mapping frameworks like Dozer are helpful for this sort of thing.

    If your mapping is pretty shallow some simple reflection, code generation or commons beanutils will suffice.