EJB设计模式1

第一个设计模式非常简单。一个公司和雇员的EntityBean和
下面给出的EntityBean的代码片断是类似的。它们是由jbuilder4的
EntityBean模版生成的。所有的字段都声明为public的cmp字段。


CodesnippetforCompanyEntityBean
publicclassCompanyBeanimplementsEntityBean{
EntityContextentityContext;
publicIntegercomId;//theprimarykey
publicStringcomName;//thecompanyname
publicStringcomDescription//basicdescription
publicTimestampmutationDate//explainedlater
publicIntegerejbCreate(<params>)throws
CreateException{
returnnull;
}
//variousget()andset()foreverycolumn/field
//whichareexposedintheRemoteInterfaceaswell

CodesnippetforEmployeeEntityBean
publicclassEmployeeBeanimplementsEntityBean{
EntityContextentityContext;
publicIntegerempId;//theprimarykey
publicIntegercomId;//thecompanyforeignkey
publicStringempFirstName;//theemployeefirstname
publicStringempLastName//theemployeelastname
publicTimestampmutationDate//explainedlater
publicIntegerejbCreate(<params>)throws
CreateException{
returnnull;
}
//variousget()andset()foreverycolumn/field
//whichareexposedintheRemoteInterfaceaswell


这个设计模式虽然很简单,但是却有很多缺点,比如,对每一个
字段的访问都会导致对get()和set()方法的一次远程调用。而远
程过程调用(RPCs)是非常耗费资源的,并且,对于在实际中通
常要求的组合的访问会导致一系列的远程调用。可以说,这个模
式在实际中可用性很差。上面展示的设计模式可以作为其他设计
模式的基础,比如RAD,原型设计,测试等。这时,那个代表雇
员的EmployeeEntityBean并没有展示出在雇员和公司之间有何
关系。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值