Khi sử dụng Container-Managed Persistence đậu thực thể (CMP), nó là một cộng với chính mà các container có thể xử lý tất cả các logic kiên trì và lập bản đồ O / R, cũng như dữ liệu bộ nhớ đệm, thay mặt cho nhà phát triển. | Pattern Code Listing 209 public void setWithdrawAccountID String withdrawAccountID withdrawAccountID public void setDepositAccountID String depositAccountID depositAccountID public void setTransferAmount double transferAmount transferAmount public double getDepositAccountBalance return depositAccountBalance public double getWithdrawAccountBalance return withdrawAccountBalance public TransferFundsCommand Command Superclass package import public abstract class Command implements Serializable public abstract void execute throws CommandException Commandserver Session Bean package import . import import . public class CommandServerBean implements SessionBean SessionContext ctx 210 Appendix public void CommandServer public Command executeCommand Command aCommand throws CommandException try catch CommandException e throw e return aCommand public void ejbActivate throws EJBException public void ejbCreate throws CreateException public void ejbPassivate throws EJBException public void ejbRemove throws EJBException public void setSessionContext final SessionContext p1 throws EJBException p1 CommandException package public class CommandException extends Exception Exception wrappedException public CommandException public CommandException Exception e e Pattern Code Listing 211 Exception getWrappedException return wrappedException public CommandException String s super s CommandTarget Interface package interface CommandTarget Command executeCommand Command aCommand throws CommandException EJBCommandTarget package import import import .