dto

VO、DTO、DO、PO是什么?

孤者浪人 提交于 2019-11-26 12:16:39
概念 VO (View Object ): 视图对象,用于展示层,它的作用是把某个指定页面(或组件)的所有数据封装起来。 DTO (Data Transfer Object ): 数据传输对象,这个概念来源于J2EE的设计模式,原来的目的是为了EJB的分布式应用提供粗粒度的数据实体,以减少分布式调用的次数,从而提高分布式调用的性能和降低网络负载,但在这里,我泛指用于展示层与服务层之间的数据传输对象。 DO (Domain Object ): 领域对象,就是从现实世界中抽象出来的有形或无形的业务实体。 PO (Persistent Object ): 持久化对象,它跟持久层(通常是关系型数据库)的数据结构形成一一对应的映射关系,如果持久层是关系型数据库,那么,数据表中的每个字段(或若干个)就对应PO的一个(或若干个)属性。 模型: 下面以一个时序图建立简单模型来描述上述对象在三层架构应用中的位置 用户发出请求(可能是填写表单),表单的数据在展示层被匹配为VO。 展示层把VO转换为服务层对应方法所要求的DTO,传送给服务层。 服务层首先根据DTO的数据构造(或重建)一个DO,调用DO的业务方法完成具体业务。 服务层把DO转换为持久层对应的PO(可以使用ORM工具,也可以不用),调用持久层的持久化方法,把PO传递给它,完成持久化操作。 对于一个逆向操作,如读取数据

How to work with DTO in Spring Data REST projects?

一世执手 提交于 2019-11-26 11:04:01
问题 Spring Data REST automates exposing only domain object. But most often we have to deal with Data Transfer Objects. So how to do this in SDR way? 回答1: An approach of how to work with DTO in Spring Data REST projects The working example is here Entities Entities must implement the Identifiable interface. For example: @Entity public class Category implements Identifiable<Integer> { @Id @GeneratedValue private final Integer id; private final String name; @OneToMany private final Set<Product>

Best Practices For Mapping DTO to Domain Object?

白昼怎懂夜的黑 提交于 2019-11-26 08:48:26
问题 I\'ve seen a lot of questions related to mapping DTOs to Domain Objects, but I didn\'t feel they answered my question. I\'ve used many methods before and have my own opinions but I\'m looking for something a little more concrete. The Situation: We have many domain objects. We are using a CSLA model so our domain objects can be pretty complex and they contain their own data access. You do not want to pass these around on the wire. We are going to be writing some new services that will return

How to quickly check if two data transfer objects have equal properties in C#?

て烟熏妆下的殇ゞ 提交于 2019-11-26 05:55:29
问题 I have these data transfer objects: public class Report { public int Id { get; set; } public int ProjectId { get; set; } //and so on for many, many properties. } I don\'t want to write public bool areEqual(Report a, Report b) { if (a.Id != b.Id) return false; if (a.ProjectId != b.ProjectId) return false; //Repeat ad nauseum return true; } Is there a faster way to test if two object with only properties have the same values (something that doesn\'t require one line of code or one logical

Difference between DTO, VO, POJO, JavaBeans?

心已入冬 提交于 2019-11-26 03:14:41
问题 Have seen some similar questions: What is the difference between a JavaBean and a POJO? What is the Difference Between POJO (Plain Old Java Object) and DTO (Data Transfer Object)? Can you also please tell me the contexts in which they are used? Or the purpose of them? 回答1: JavaBeans A JavaBean is a class that follows the JavaBeans conventions as defined by Sun. Wikipedia has a pretty good summary of what JavaBeans are: JavaBeans are reusable software components for Java that can be

Why are data transfer objects (DTOs) an anti-pattern?

夙愿已清 提交于 2019-11-26 03:03:34
问题 I\'ve recently overheard people saying that data transfer objects (DTOs) are an anti-pattern . Why? What are the alternatives? 回答1: Some projects have all data twice . Once as domain objects, and once as data transfer objects. This duplication has a huge cost , so the architecture needs to get a huge benefit from this separation to be worth it. 回答2: DTOs are not an anti-pattern. When you're sending some data across the wire (say, to an web page in an Ajax call), you want to be sure that you

REST API - DTOs or not? [closed]

与世无争的帅哥 提交于 2019-11-26 01:44:00
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 3 years ago . I am currently creating a REST-API for a project and have been reading article upon article about best practices. Many seem to be against DTOs and simply just expose the domain model, while others seem to think DTOs (or User Models or whatever you want to call it) are bad

any tool for java object to object mapping? [closed]

女生的网名这么多〃 提交于 2019-11-26 01:23:06
问题 I am trying to convert DO to DTO using java and looking for automated tool before start writing my own. I just wanted to know if there any free tool available for the same. 回答1: You could try Dozer. Dozer is a Java Bean to Java Bean mapper that recursively copies data from one object to another. Typically, these Java Beans will be of different complex types. Dozer supports simple property mapping, complex type mapping, bi-directional mapping, implicit-explicit mapping, as well as recursive

What is Data Transfer Object?

浪子不回头ぞ 提交于 2019-11-25 23:45:44
问题 What is a Data Transfer Object? In MVC are the model classes DTO, and if not what are the differences and do we need both? 回答1: A Data Transfer Object is an object that is used to encapsulate data, and send it from one subsystem of an application to another. DTOs are most commonly used by the Services layer in an N-Tier application to transfer data between itself and the UI layer. The main benefit here is that it reduces the amount of data that needs to be sent across the wire in distributed

Plain Old CLR Object vs Data Transfer Object

前提是你 提交于 2019-11-25 23:45:15
问题 POCO = Plain Old CLR (or better: Class) Object DTO = Data Transfer Object In this post there is a difference, but frankly most of the blogs I read describe POCO in the way DTO is defined: DTOs are simple data containers used for moving data between the layers of an application. Are POCO and DTO the same thing? 回答1: A POCO follows the rules of OOP. It should (but doesn't have to) have state and behavior. POCO comes from POJO, coined by Martin Fowler [anecdote here]. He used the term POJO as a