-
Book Overview & Buying
-
Table Of Contents
Google Web Toolkit 2 Application Development Cookbook
By :
In RPC, the client will send and receive DTOs, but the server needs pure JPA objects to be used by the Entity Manager. That's why, we need to transform from DTO to JPA entity class and vice versa. In this recipe, we will learn how to map the entity class and DTO.
Create the entity and DTO classes.
Open the Branch entity class and define a constructor with a parameter of type BranchDTO. The constructor gets the properties from the DTO and sets them in its own properties:
public Branch(BranchDTO branchDTO)
{
setBranchId(branchDTO.getBranchId());
setName(branchDTO.getName());
setLocation(branchDTO.getLocation());
}
This constructor will be used to create the Branch entity class object from the BranchDTO object.
In the same way, the BranchDTO object is constructed from the entity class object, but in this case, the constructor is not defined. Instead, it is done where it is required to construct DTO from the entity class.
Change the font size
Change margin width
Change background colour