PDA

View Full Version : Mapping domain types to schema types



dan.baumann
Oct 31st, 2006, 10:03 AM
I'm currently looking at the airline example.

The decoupling of domain types from schema types makes a lot of sense to me, because I've seen them drift apart in real world projects (which is a pain if you didn't expect it).

So while I appreciate the design, shouldn't there be a simpler approach to conversion than the manual one found in the several convertToSchemaType() methods in GetFlightsEndpoint? Initially, the classes in both packages tend to be identical. Would't it make sense to use another mapping solution?

Or am I missing something?

Thanks,
Dan

Arjen Poutsma
Nov 1st, 2006, 02:15 AM
Yes, I could have used something like Jibx, which allows you to map the XML to domain objects, or better yet, Toplink's OXM support, which allows you to map XPath expressions to properties.

Alternatively, I could have used Dozer (http://dozer.sourceforge.net/) to map the schema beans to the domain beans.

So yes, there are better solutions, but all of these would have made the sample more complicated & added more dependencies. It's a tradeoff...

dan.baumann
Nov 1st, 2006, 05:18 AM
Thanks for the clarification. Just wanted to make sure I'm not misunderstanding the example.