Database commits and rollbacks for controller commands

Throughout the execution of a controller command, data is often created or updated. In many cases, the database must be updated with the new information at the end of the transaction.

The solution controller marks the beginning of the transaction before calling the business logic facade. When the execution of the controller command is complete, the controller command returns a view name to the controller. The controller is responsible for marking the end of the transaction. The actual point at which the transaction ends (before or after invoking the view) is dependent upon the type of view used.

For Web applications, the solution controller determines the view type by looking up the view name in the Struts configuration files:

In the cases where the view command executes under the same transaction scope as the controller command, an error in the view command execution causes a rollback of the entire transaction. This may or may not be the desired outcome, depending upon your business logic.

Related concepts

Command types