Daily Record [2004-9-2 CMP Solution]

xiaoxiao2021-03-06  73

In the process of learning the Entity EJB, it is impossible to understand how the CMP manages the transaction because it is only the incoming value in the EJBCREATE method of the Entity Bean, and the insertion of the table is completed by the container; if there is an exception, how does it roll back?

? In the previous programming mode, the service class get the link, set the automatic submission of the transaction as a fake, then call the DAO class to complete the insertion, update, etc. of the data, and finally submit a transaction by the business class, and the abnormality rollback transaction; This can complete the processing of the transaction. CMP has not found similar

Con.commit (); con. rollback () method for transaction operations.

?

Find online for a long time, still can't understand, initially think that Entity Bean also has business logic processing, that is, each method in an Entity bean is completed a business logic, which naturally involves an operation between a large number of different tables (insertion , Update, deletion, query, etc. The processing of the transaction is completed in each method of the Entity Bean, so that the client can directly call a certain method of an Entity Bean to complete a business logic processing.

?

Later, in the WEBLOGIC example, it is not the case. All Entity Bean is a simple operation of a table, rarely involving other tables; later in http://dev2dev.bea.com.cn? Website forum In the post, I finally understand how CMP manages business (huh, thank you.).

?

? 1) CMP is configured by EJB-JAR.XML

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Required

??? The method provided by Entity Bean is different from the previous development mode, con.setautocommit (false), con.Mit () is the container is automatically completed, that is, whether it is BMP or CMP, although in the program The operation of the database is completed, but in fact may not really update to the database, when updating the container and related profile decision.

2) The data source in WebLogic must be configured as TXDataSource, otherwise the transaction cannot be guaranteed.

?

Overview, in the development of EJB, the processing of business logic can be completed by the session bean. Compared with routine application development, it has the following two points:

? 1) Distributed

? 2) Object pool

转载请注明原文地址:https://www.9cbs.com/read-120952.html

New Post(0)