Data Transfer Object The client layer in an EJB system requires a method of transferring large block data to the server. How can clients can exchange large block data with servers without multiple fine-grained network calls? In a distributed application, the client and server interaction usually may have two reasons. The first is to read some data from the server; the second is to change the data on the server by creating, updating, deleting data. In an EJB environment, these types of operations typically involve the client (servlet, applet, etc.) And a session bean, Entity Bean, swap data. When a huge number of data needs to be exchanged, this can be achieved by two methods: 1. Load a number of parameters to a method call (when updating data on the server), or 2. Many fine particle size calls are taken from the server (when the client needs to read data from the server). When processing a large number of parameters, the previous method will quickly lose control, and the latter method will be a performance killer. Imagine a situation when the client UI needs to display a collection of attributes on the server; these attributes exist in an Entity Bean or can be accessed by a session bean. One way to obtain the data it needs to get the data it needs is to perform multiple calls to the server, as shown in Figure 2.1. The problem with this method is that each call is called a network call, which requires sequence and reverse sequence of return values. When the EJB server intercepts the call to the server and blocks the client, and At this time, it is of course unknown to the attribute. Further, if the client does not use the Java Transaction API Client-Demarcated transaction, each method call may actually be executed in its own separate transaction. Executing multiple network calls in this form will result in severe performance degradation. A better alternative is needed, which allows the client to get all the required data in a large block call. In summary: Creating a normal Java class called Data Transfer Object, contains and encapsulated bulk data in a NetWork Transportable bundle (tie, bundle). A common data transfer object is a serializable java class that represents a snapshot of some server-side data (Snapshot), as the following example: import java.io.Serializable; public class SomeDTO implements Serializable {private long attribute1; private String attribute2 Private string attribute3; ... public long getattribute1 (); public string getAttribute2 (); public string getattribute3 (); ...} // Somesto can use Data Transfer Object as reading operations in a distributed system Update operation. When a client needs to update some of the data on the server, it can create a DTO that encapsulates all the information that needs to be updated, and transmits to the server (usually a session facade) to process. Of course, it can also use trillions of fine granular parameters to transmit data to the server, but this is a very fragile approach. Whenever a parameter needs to be increased or deleted, the method signature needs to change. By using the DTO package method parameters, it is only isolated to DTO yourself. The place where Data Transfer Object is pronounced is read operation.