When encountering these messy data models, I was really confused, and the design architecture was also messy. I didn't know how to get the corresponding package name based on the data model. I also searched through various materials online, but no one explained it in a simple and understandable way. So, I organized it based on my own experience.
POJO
【plain old java object】: Plain Java objects that can serve as the basis for other data models.VO
【value object】: Value objects are immutable objects with no unique ID identifier, used to represent a set of values.- Can contain simple business logic operations.
- VOs typically override the equals and hashCode methods for value-based comparisons.
PO / Entity
: Entities must have a unique ID identifier, meaning that if two entities have the same property values, they are not considered equal. PO is a Java object mapped to a database table.DTO
【data transfer object】: DTOs are used to transfer data between different layers.- Do not contain any business logic.
Rich Model
: Rich Model = PO + Business Logic.BO
【Business object】: Business objects contain business logic and are only used in the Service layer.