Cnblogs has not been added for a long time. I checked it out yesterday and found it is still betterArticleNot finished. Although not very happy to write, but it is better to do things first and foremost, just write it :)
For business logic encapsulation, we use Command pattern in the project. For the reason, the book "Java persistence with hibernate" is quite good. I will not elaborate on it any more, just copy it:
a third tier application may move the presentation layer to a separate virtual machine, the current persistence context can't be held open anymore until the view has been rendered. this is typically the case in three-tiered EJB application, or in an architecture with a rich client in a separate process.
If the presentation layer runs in a different process, you need to minimize the requests between this process and the Tier that runs the business and persistence layers of the application. this means that you can't use the previous lazy approach, where the view is allowed to pull data from the domain model objects as needed. instead, the Business tier must accept responsibility for fetching all data that is needed ubsequently for rendering the view.
Although certain patterns that can minimize remote communication, such as the Session Facade and data transfer object (DTO) patterns, have been widely used in the Java developer community, we want to discuss a slightly different approach. the Command pattern (often also called EJB command) is a sophisticated solution that combines the advantages of other strategies.
For specific interfaces and implementations, you can refer to some of the design patterns books, or you can write for Java persistence with hibernateCodeAdd more methods to the command, and use generics to implement commandhandle.
Another problem is: one operation, one session. in this two-tier system, we can use open session in view (osiv) to solve this problem. There are many solutions for the three-tier system, we used a combination of different commands to solve this problem in one command. The most basic idea was from Java persistence with hibernate. I will not discuss it much.