简体   繁体   中英

Difference between DTO and Spring Data Projection in Spring Boot

I'm confused about DTO and Spring Data Projection, when I open an entity file there is an option to create DTO "Create DTO" and Spring Data Projection "Create Spring Data Projection" in Intelij IDEA IDE.

Intellij IDEA Capture

What are the functions and differences between the two? when to use it between DTO and Spring Data Projection. Is there a reference that shows the one-to-one differences in tabular form? I googled, the results appear ambiguous between the two things

About projections and good topic about DTO . From documentation spring.

Difference: The projection is created using the interface . DTO is created using a class .

Since one (projection) is created using an interface and another (DTO) using a class, it already makes a big difference.

Simply put, a DTO is a data transfer object, which you can think of as a receive parameter。 However, Spring Data Projection returns Data. When a query does not match all the fields in the database, such as a partial view of a field, it is received with Spring Data Projection

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM