Backend Development 6 min read

Understanding DTO, BO, PO, and VO in Backend Development

This article explains the concepts of Data Transfer Object (DTO), Business Object (BO), Persistent Object (PO), and Value Object (VO) in backend development, compares their roles, provides Java code examples, and discusses how to configure Spring MVC to filter null fields, while also including promotional content for IDE licenses.

Top Architecture Tech Stack
Top Architecture Tech Stack
Top Architecture Tech Stack
Understanding DTO, BO, PO, and VO in Backend Development

DTO, BO, PO, and VO are common object models used in backend development to separate concerns and manage data flow across layers.

DTO (Data Transfer Object) carries data between services or from server to client without business logic.

BO (Business Object) encapsulates business data and related operations, often used to filter and control data before entering the service layer.

PO (Persistent Object) represents a database record, mapping directly to table fields and used by ORM frameworks for CRUD operations.

VO (Value Object) is used in the presentation layer to hold data needed for UI rendering, often a subset of DTO fields.

Example PO class:

@Data
public class User implements Serializable {
    private Long id;
    private String username;
    private String password;
    private String identityCard;
    private String gender;
    private String location;
    private String userImage;
    private String phoneNumber;
    private String createTime;
    private String updateTime;
    @TableLogic
    private int isDelete;
}

Corresponding DTO:

@Data
public class UserDTO implements Serializable {
    private Long id;
    private String username;
    private String password;
    private String identityCard;
    private String gender;
    private String location;
    private String userImage;
    private String phoneNumber;
}

Business Objects for login and update:

@Data
public class UserLoginBO implements Serializable {
    private String username;
    private String password;
}
@Data
public class UserUpdateBO implements Serializable {
    private Long id;
    private String username;
    private String password;
    private String identityCard;
    private String gender;
    private String location;
    private String userImage;
    private String phoneNumber;
}

The article explains how DTO serves as a large entry point, BO filters data before the service layer, and PO is used before the infrastructure layer. It also notes that VO can be omitted by configuring Spring MVC to ignore null fields.

Configuration example to globally ignore null values in JSON responses:

@Configuration
public class GlobalConfig extends WebMvcConfigurationSupport {
    @Override
    protected void configureMessageConverters(List
> converters) {
        super.configureMessageConverters(converters);
        converters.add(mappingJackson2HttpMessageConverter());
    }
    private MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
        ObjectMapper objectMapper = new ObjectMapper();
        objectMapper.configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
        objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
        return new MappingJackson2HttpMessageConverter(objectMapper);
    }
}

At the end, the article includes promotional information offering free activation codes for IDEs such as IntelliJ IDEA and PyCharm, encouraging readers to contact the author for paid licenses.

JavaBackend DevelopmentDTOSpring MVCPOVOBO
Top Architecture Tech Stack
Written by

Top Architecture Tech Stack

Sharing Java and Python tech insights, with occasional practical development tool tips.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.