POJOs populated by Hibernate are entities, business objects or data transfer objects?

不问归期 提交于 2019-12-10 20:33:32

问题


I have classes (POJOs) annotated with JPA and populated by Hibernate.

Since those objects are transfered from database by DAOs to Business Services and doesn't have any behavior nor hold business logics, they are DTOs.

But I have read some articles that they are business entities or business objects and this got me confused.

Can someone clarify the differences?


回答1:


Business Entities encapsulate the data that is important to the business. As opposed to controllers that encapsulate business logic. The controllers implement the business processes and make use of the entities.

I would not call these objects DTOs because they do not only transfer data from one point to the next. They create a model of the business that can be acted upon by the controllers.




回答2:


Those are DTO`s.

Object w/o behavior is just a bag where to store state and transfer it around (definition of DTO`s).
Business objects are supposed to have behavior.

Good news are - it's You who decides what they should be.
Adding proper behavior would make them business objects. Hibernate just provides persistence.



来源:https://stackoverflow.com/questions/6177082/pojos-populated-by-hibernate-are-entities-business-objects-or-data-transfer-obj

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!