четверг, 28 января 2010 г.

Hibernate ResultTransformer and hand-coded mapping

I have noticed that fairly large number of people don't know about hibernate result transformers. Moreover I saw monsters like this:

Obviously it is not normal to do hand-coded mapping with Hibernate. There are several ways to avoid such a nasty code.
Call DTO class constructor directly from your request

It is not convenient to use constructor in case of many properties:

ResultTransformer can be used with native sql queries too:

It is much more easy to use constructors or ResultTransformer instead of hand-coded mapping, isn't it ?

Комментариев нет: