-
Feb 17th, 2011, 04:33 PM
#1
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.
-
Feb 17th, 2011, 10:24 PM
#2
If you need to go deep, mapping frameworks like Dozer are helpful for this sort of thing.
http://dozer.sourceforge.net/documen...complex-to-map
If your mapping is pretty shallow some simple reflection, code generation or commons beanutils will suffice.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules