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.
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
CodePudding user response:
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
CodePudding user response:
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.