When I encountered these messy data models, I was really confused. The architecture design was also a mess. I didn't know how to get the corresponding package name based on the data model. I 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.
- Usually overrides the equals and hashCode methods for value-based comparison.
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】: DTO is used to transfer data between different layers.- Does not contain any business logic.
Rich Model
: Rich Model = PO + Business Logic. If a PO has business logic, then it is a rich model.BO
【Business object】: Business objects contain business logic and are only used in the Service layer.