ejb中relationship的问题,高手请进
1、建立实体BEAN 有两个实体BEAN,DhbDdxgdb、Rybm,关系是多对一。
2、建立session bean 我在sessionbean 中调用他们代码如下:结果没问题
Collection c=null;
//J2eeUser4 userbm=null;
RybmHome rybmhome=null; //HOME
Rybm rybm=null; //LOCAL
DhbDdxgdb dhbddxgdb=null;
try{
Context ctx = new InitialContext();
Object objRef = ctx.lookup("Rybm");
rybmhome = (RybmHome) javax.rmi.PortableRemoteObject.narrow(objRef,
RybmHome.class);
rybm=rybmhome.findByPrimaryKey("xt12");
//out.println(rybm.getRybm());
c=rybm.getDhbDdxgdb();
iter=c.iterator();
/* while (iter.hasNext())
{
dhbddxgdb=(DhbDdxgdb)iter.next();
System.out.println(dhbddxgdb.getDhr());
}*/
}catch (Exception ee)
{
System.out.println("error in sessionbean");
}
////////////////////////////////////////////////////////
3、在客户调用:然后我又到 jsp调用sessionbean 代码如下:
Collection c=null;
Iterator iter=null;
//J2eeUser4 userbm=null;
DhbDdxgdb dhbddxgdb=null;
getmcp7Home rybmhome=null; //HOME
getmcp7 rybm=null; //LOCAL
Context ctx = new InitialContext();
Object objRef = ctx.lookup("getmcp7");
rybmhome = (getmcp7Home) javax.rmi.PortableRemoteObject.narrow(objRef,
getmcp7Home.class);
rybm=rybmhome.create();
//out.println(rybm.getRybm());
iter=rybm.getResult();
//out.println(c.size());
//iter=c.iterator();
while (iter.hasNext())
{
dhbddxgdb=(DhbDdxgdb)iter.next();
out.println(dhbddxgdb.getDhr());
}
//////////////////////////////////////////////////////////////////////
4、出现错误如下:org.apache.jasper.JasperException: The iterator of a CMR collection may only be used within the transction in which it was created
///////////////////////////////////////////
5、问题:我如何解决?是否只能在sessionbean里把所有数据写到数组,然后把数组返回给jsp?
2、建立session bean 我在sessionbean 中调用他们代码如下:结果没问题
Collection c=null;
//J2eeUser4 userbm=null;
RybmHome rybmhome=null; //HOME
Rybm rybm=null; //LOCAL
DhbDdxgdb dhbddxgdb=null;
try{
Context ctx = new InitialContext();
Object objRef = ctx.lookup("Rybm");
rybmhome = (RybmHome) javax.rmi.PortableRemoteObject.narrow(objRef,
RybmHome.class);
rybm=rybmhome.findByPrimaryKey("xt12");
//out.println(rybm.getRybm());
c=rybm.getDhbDdxgdb();
iter=c.iterator();
/* while (iter.hasNext())
{
dhbddxgdb=(DhbDdxgdb)iter.next();
System.out.println(dhbddxgdb.getDhr());
}*/
}catch (Exception ee)
{
System.out.println("error in sessionbean");
}
////////////////////////////////////////////////////////
3、在客户调用:然后我又到 jsp调用sessionbean 代码如下:
Collection c=null;
Iterator iter=null;
//J2eeUser4 userbm=null;
DhbDdxgdb dhbddxgdb=null;
getmcp7Home rybmhome=null; //HOME
getmcp7 rybm=null; //LOCAL
Context ctx = new InitialContext();
Object objRef = ctx.lookup("getmcp7");
rybmhome = (getmcp7Home) javax.rmi.PortableRemoteObject.narrow(objRef,
getmcp7Home.class);
rybm=rybmhome.create();
//out.println(rybm.getRybm());
iter=rybm.getResult();
//out.println(c.size());
//iter=c.iterator();
while (iter.hasNext())
{
dhbddxgdb=(DhbDdxgdb)iter.next();
out.println(dhbddxgdb.getDhr());
}
//////////////////////////////////////////////////////////////////////
4、出现错误如下:org.apache.jasper.JasperException: The iterator of a CMR collection may only be used within the transction in which it was created
///////////////////////////////////////////
5、问题:我如何解决?是否只能在sessionbean里把所有数据写到数组,然后把数组返回给jsp?
...全文
相关推荐
j2ee开发完整代码
**EJB**:EJB是J2EE的组件模型,用于封装业务逻辑,提供分布式服务。
EJB系统开发实战录之二
而在EJB模型中,也有相应的机制来模拟实体之间的关系,即EJB Relationship。
java B/S架构设计 crm客户关系管理系统
二、CRM系统CRM(Customer Relationship Management)客户关系管理系统是一种旨在优化企业与客户之间关系的软件工具。
EJB笔记--介绍了EJB的用处以及编程方法
EJB角色- **EJB客户**:发起对EJB组件的请求。- **EJB组件**:封装业务逻辑的实体。- **EJB容器**:管理和调度EJB组件的运行时环境。
EJB-Struts
**CRMApplication** - 可能是业务逻辑层,包含EJB组件,处理CRM(Customer Relationship Management)相关的业务操作。3.


