cmr调用错误:A CMR collection may only be used within the transction in which it was created
1、两个实体BEAN CYDMDB DHBDDXGDB,关系是一对多。
/////////////////////////////////////////////////////////////
2、在sessionbean中调用函数:getResult() 代码如下:
Context ctx = new InitialContext();
Object objRef = ctx.lookup("Cydmdb");
home = (CydmdbHome) javax.rmi.PortableRemoteObject.narrow(objRef,
CydmdbHome.class);
testbean=home.findByPrimaryKey("Y700");//find
c=testbean.getDhbDdxgdb();
//返回一个collection,这个collection里有多个dhbddxgdb对象
return c;//本函数返回。
/////////////////////////////////////////////////////////////
3、在servlet里边的调用如下:
Context ctx = new InitialContext();
Object objRef = ctx.lookup("getcmp7");
home = (getcmp7Home) javax.rmi.PortableRemoteObject.narrow(objRef, getcmp7Home.class);
getcmp7=home.create(); //create local
Collection c=rybm.getResult();//////////////////问题就出在这里
out.println(c.size());
/////////////////////////////////////////////////////////////
4、错误提示:
A CMR collection may only be used within the transction in which it was created
/////////////////////////////////////////////////////////////
5、为什么出现这样的错误,应该如何解决?
谢谢大家