Is using data transfer objects in ejb3 considered best practice

后端 未结 6 558
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-02-07 22:01

Although obviously not all scenarios can be covered by a single design, is it generally felt now that ORM classes should be passed to and fro between the presentation and busine

6条回答
  •  再見小時候
    2021-02-07 22:37

    working only with entities would be fine if the GUI controller sends object propertires to the forms and not entity objects. On the other hand, if entities are used and these entities have many-to-one relationships, then one should expect to see some nasty exceptions, if the entities are not eagerly fetched by the entity manager.

    Such situations can be observed when attempting to populate tags of Spring MVC for example, or similar constructs of other GUI components.

    Furthermore, DTOs are a very good place for placing extra annotations such as validation annotations or JAXB, etc

提交回复
热议问题