在EJB里,SESSION BEAN怎样封装实体BEAN,能加点代码? 为什么不使用facade模式?在session bean里调用实体bean 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 jndi,然后就随便你了,想怎么玩就怎么玩了 为什么不使用facade模式?在session bean里调用实体bean---------------同意得很。 你在session bean 中调用实体BEAN的代码和客户端调用实体BEAN差不多,不过记着在描述文件中要讲他们的引用关系添上。 建议看看《Core J2EE Patterns》,就什么都清楚了。 就向 实体bean 一般的 客户端程序一样,没有什么 特殊的.... 人家要代码,咱就给代码。假如有实体Bean Student那么,再创建一个SessionBean比如叫StuController,创建一个方法,封装其按主键查找的Home接口方法。public Student getUserById(String _sId) throws FinderException { Context cxt = new InitialContext("Student"); Object o = cxt.lookup("Student"); StudentHome stuHome = (StudentHome) o ; return stuHome.findByPrimary(_sId); }然后在Jsp中调用SessionBean的方法就可以了。 jsp 站 隔两天网站就出现503 Service Unavailable 跪求大虾帮忙 谁用过 NetPayClient 在线支付 h:commandLink 右键打开问题 有哪位用过FullBI工具 怎么感觉JSP 比ASP。NET 难很多啊 请教大神关于ByteArrayOutputStream的一些用法 tomcat高手救命啊 如何用java向sqlserver中存入大文件 关于电子商务网站多语种数据库设计的问题 哪儿有DROOL的文档???? excel表的多页合并问题!很急!请多帮忙! about struts jbuilderX
在session bean里调用实体bean
---------------
同意得很。
假如有实体Bean Student
那么,再创建一个SessionBean比如叫StuController,创建一个方法,封装其按主键查找的Home接口方法。
public Student getUserById(String _sId) throws
FinderException {
Context cxt = new InitialContext("Student");
Object o = cxt.lookup("Student");
StudentHome stuHome = (StudentHome) o ;
return stuHome.findByPrimary(_sId);
}
然后在Jsp中调用SessionBean的方法就可以了。