好像不适合,
不过你可以使用接口javax.ejb.UserTranscation控制自己的事务划分。
你的SessionBean必须为有状态的

解决方案 »

  1.   

    《continue》
    package factory.product;import java.util.Collection;
    import javax.ejb.*;
    import java.rmi.RemoteException;public interface ProductHome extends EJBHome {  Product create(String product, String name, 
                     Collection routingInstructions) 
                     throws RemoteException, CreateException;  Product findByPrimaryKey(String product) 
              throws RemoteException, FinderException;
    }
    package factory.product;import javax.ejb.*;
    import java.rmi.RemoteException;import java.util.Collection;abstract public interface Product extends EJBObject {
      abstract public String getProduct() throws RemoteException;  abstract public String getName() throws RemoteException;
      abstract public void setName(String name) throws RemoteException;  // Business methods
      abstract public void addRoutingInstruction(int sequence, String instruction) 
              throws RemoteException;  public void deleteRoutingInstruction(int sequence) 
        throws NoSuchRoutingException, RemoteException;  abstract public Collection getRoutingInstructions()  throws RemoteException;
      abstract public void setRoutingInstructions(Collection c) throws RemoteException;}
    package factory.product;import java.util.Collection;
    import javax.ejb.*;
    import java.rmi.RemoteException;public interface ProductLocalHome extends EJBLocalHome {  LocalProduct create(String product, String name, 
                     Collection routingInstructions) 
                     throws CreateException;  LocalProduct findByPrimaryKey(String product) 
              throws FinderException;
    }
    package factory.product;import javax.ejb.*;
    import java.rmi.RemoteException;import java.util.Collection;abstract public interface LocalProduct extends EJBLocalObject {
      abstract public String getProduct();  abstract public String getName();
      abstract public void setName(String name);  // Business methods
      abstract public void addRoutingInstruction(int sequence, String instruction);  public void deleteRoutingInstruction(int sequence)
        throws NoSuchRoutingException;  abstract public Collection getRoutingInstructions();
      abstract public void setRoutingInstructions(Collection c);}
    package factory.product;import javax.ejb.*;
    import java.util.Collection;
    import java.util.List;
    import java.util.LinkedList;
    import java.util.Arrays;
    import java.util.Iterator;import java.rmi.RemoteException;abstract public class ProductEJB implements EntityBean
    {
      private Collection routingInstructions = new LinkedList();  abstract public String getProduct();
      abstract public void setProduct(String p);
      abstract public String getName();  abstract public void setName(String name);  // Business methods  public void setRoutingInstructions(Collection c) {
        routingInstructions = c;
      }  public Collection getRoutingInstructions() {
        return routingInstructions;
      }   public void addRoutingInstruction(int sequence, String instruction) {
        routingInstructions.add(new RoutingInstruction(sequence, 
                                                       instruction));
      }   public void deleteRoutingInstruction(int sequence) 
        throws NoSuchRoutingException
      {
        Collection instructions = getRoutingInstructions();
        Iterator iter = instructions.iterator();
        while (iter.hasNext()) {
          RoutingInstruction ri = (RoutingInstruction) iter.next();
          if (ri.sequence == sequence) {
            iter.remove();
            setRoutingInstructions(instructions);
            return;
          } 
        } 
        throw new NoSuchRoutingException();
      }   public void replaceRoutingInstructions(RoutingInstruction[] newRoutingInstructions)
      throws RemoteException
      {
        LinkedList li = new LinkedList();
        for (int i = 0; i < newRoutingInstructions.length; i++) {
          li.add(newRoutingInstructions[i]);
        }
        setRoutingInstructions(li);
      }  // Framework and lifecycle methods  public String ejbCreate(String product, String name, 
                              Collection routingInstructions)
    //     throws RemoteException
      {
        setProduct(product);
        setName(name);
        setRoutingInstructions(routingInstructions);
        return null;
      }   public void ejbPostCreate(String product, String name, 
                                Collection routingInstructions) {}  public void ejbActivate() {}  public void ejbLoad() {}  public void ejbPassivate() {}  public void ejbRemove() {}  public void ejbStore() {}  public void setEntityContext(EntityContext ctx) {}  public void unsetEntityContext() {}
    }
      

  2.   

    可以使用象erp提交作业的方式来实现,对页面来说只是提交一个作业,
    后台运行,是否成功,通过另外的途径去访问。这种方式erp中用的很多的
      

  3.   

    to  richiewong(墨玉) :
    是struts结构,不过后台也有ejb层的模型运算to  cool() :
    这个我没什么经验,如果将一个长事务分解成若干短事务是不是
    会好一点,处理一个事务,记录状态
    ……另外,如果利用自动刷新,防止用户超时是不是也可以呢?
      

  4.   

    长事务(Long Transaction):一个有状态的会话豆(Bean)收集数据,并在
    一个短数据库事务中完成工作
      

  5.   

    ?如果Web层timeout,通常的设计模式中
    Stateful Session Bean就会被remove掉了,应该还
    有一套提交作业的流程,在用户重新登陆时候,恢复
    上一次的会话状态,并且提交作业,这里自动/手工又
    要看需求决定了