简体   繁体   English

Spring Boot 中 DTO 和 Spring 数据投影的区别

[英]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. 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 Intellij IDEA 捕获

What are the functions and differences between the two?两者的作用和区别是什么? when to use it between DTO and Spring Data Projection.何时在 DTO 和 Spring 数据投影之间使用它。 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 .关于DTO预测和好话题。 From documentation spring.来自文档 spring。

Difference: The projection is created using the interface .区别:投影是使用界面创建的。 DTO is created using a class . DTO 是使用class创建的。

Since one (projection) is created using an interface and another (DTO) using a class, it already makes a big difference.由于一个(投影)是使用接口创建的,另一个(DTO)是使用 class 创建的,因此它已经产生了很大的不同。

Simply put, a DTO is a data transfer object, which you can think of as a receive parameter。 However, Spring Data Projection returns Data.简单来说,一个DTO就是一个数据传输object,可以认为是一个接收参数。然而,Spring Data Projection返回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当查询不匹配数据库中的所有字段时,例如某个字段的部分视图,使用 Spring 数据投影接收

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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