开发者

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

开发者 https://www.devze.com 2023-03-09 01:24 出处:网络
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 h

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?


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消