|
||||||||||||
|
|
| EJB设计模式3 |
| 时间:22/04/2007 作者:网络 来源:网络 |
| 小提示→点这里把文章加入您的收藏夹,方便下次查看 |
| 设置文章字体大小:[大 中 小] |
|
设计模式3 在设计模式2中我们看到,在entity bean和struct之间 有很多重复的代码比如同样的字段声明(对应数据库中的表列)。 如果让entity bean从结构继承下来就可以避免冗余的代码。但是 这种设计,仍然不能显示beans之间的联系。 Code snippet for Company Entity Bean public class CompanyBean extends CompanyStruct implements EntityBean { EntityContext entityContext; //all fields in CompanyStruct are available for CMP public Integer ejbCreate(CompanyStruct Struct) throws CreateException { this.comId = struct.comId; //set the primary key setData(struct);//this removes some redundant code return null; } 其余的代码比如getdata()和setdata()方法的实现和设计模式2中 是完全一样的。 |
|
上一篇:EJB设计模式1
下一篇:什么时候在EJB系统中使用XML |
| 【返回】 【顶部】 【关闭】 |
| Copyright © 2005-2010 www.594k.com All Rights Reserved. |
| 版权所有:JAVA学习网
备案序号:皖ICP备06004238号 |