EJB3.0:
BEAN:@stateless
public class YWL implements YWLREMOTE{
@Persistence(unitName="bxh")
private EntityManager man; @TransactionAttribute(TransactionAttributeType.SUPPORTS)
public List findLevel_1(){
try{
Query query=man.createQuery("from ywlTabel where level='1'");
return query.getResultList();
}catch(....){}
} @TransactionAttribute(TransactionAttributeType.SUPPORTS)
public List findLevel_2_from_1(String id){
try{
Query query=man.createQuery("from ywlTabel where level='1' and parent_id="+id);
return query.getResultList();
}catch(....){}
}
}
CLIENT:public class client{
public static void main(String arg[]){
Context jndi=getInitContext();
Object ref=jndi.lookup("YWL/remote");
YWLREMOTE dao=(YWL)PortableRemoteObject.narrow(ref,YWLREMOTE.class); LIST _list=dao.findLevel_1();
for (int i=0;i<_list.size();i++){
YWL_BEAN _bean=(YWL_BEAN)_list.get(i);
LINE:ERR List _list2=dao.findLevel_2_from_1(_bean.getId());
}
}程序大概就是这样的:
可是问题是,每到LINE:ERR就报can't commit because the trasaction is in aborted state.
BEAN:@stateless
public class YWL implements YWLREMOTE{
@Persistence(unitName="bxh")
private EntityManager man; @TransactionAttribute(TransactionAttributeType.SUPPORTS)
public List findLevel_1(){
try{
Query query=man.createQuery("from ywlTabel where level='1'");
return query.getResultList();
}catch(....){}
} @TransactionAttribute(TransactionAttributeType.SUPPORTS)
public List findLevel_2_from_1(String id){
try{
Query query=man.createQuery("from ywlTabel where level='1' and parent_id="+id);
return query.getResultList();
}catch(....){}
}
}
CLIENT:public class client{
public static void main(String arg[]){
Context jndi=getInitContext();
Object ref=jndi.lookup("YWL/remote");
YWLREMOTE dao=(YWL)PortableRemoteObject.narrow(ref,YWLREMOTE.class); LIST _list=dao.findLevel_1();
for (int i=0;i<_list.size();i++){
YWL_BEAN _bean=(YWL_BEAN)_list.get(i);
LINE:ERR List _list2=dao.findLevel_2_from_1(_bean.getId());
}
}程序大概就是这样的:
可是问题是,每到LINE:ERR就报can't commit because the trasaction is in aborted state.
解决方案 »
- (高分求解)Spring AOP 出现Error creating bean with ..
- 帮忙调试一个网络商店项目(空指针异常)
- ssh配置报错,急急
- Weblogic EJB Server,Tomcat EJB Client.
- xslt转换问题,怎样在创建属性时动态指定名称
- 泛型在实例化不指定类型有什么性能损耗之类的吗
- 来谈谈你做过的网站项目的框架设计
- Driver myDriver = (Driver) Class.forName("weblogic.jdbc.oci.Driver").newInstance();
- 疑难问题:容器对实体BEAN“挂起”时,切断了和它关联的EJB对象和主健,但有没有保存它们呢?
- 求助 关于EJB的Cmp中的关联问题
- StringBuilder和String测试结果的疑问
- 请教Element 关于xml
EJB没用过 还是spring好用
改成
TransactionAttributeType.REQUIRED