2

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

Asmodeus
  • 29
  • 3
  • Not to be coy, but there's an expectation of actually attempting to solve your own problem. Have you read the Spring documentation? It's rather extensive and quite informative. If you read the docs and there's something specific you don't understand, you should mention it in your question. – Roddy of the Frozen Peas Sep 14 '22 at 03:18
  • thanks for your input, but I'm just figuring it out from the point of view of a few people here who have used it – Asmodeus Sep 20 '22 at 10:47
  • @RoddyoftheFrozenPeas would you mind explaining what is the difference between DTO, projections and DTO projections ? – humbleCodes Mar 31 '23 at 06:01

2 Answers2

2

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

xiaowei
  • 39
  • 3
0

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.

K.Nikita
  • 591
  • 4
  • 10