呵,这个帖子是这个论坛唯一一个关于处理ejb返回值的帖子,以前见过,就收藏了。

解决方案 »

  1.   

    你只讲了CachedRowSet 怎么用, 真有这么好吗?你有没有做过实验来对比?
      

  2.   

    我没做过试验,只是在网上看过此文章,所以请教大家,用此方法有什么好处?
    CachedRowSet是否也存内存里?
    在API里有这么段话:
    In summary, a CachedRowSet object can be thought of as simply a disconnected set of rows that are being cached outside of a data source. Being thin and serializable, it can easily be sent across a wire, and it is well suited to sending data to a thin client. However, a CachedRowSet object does have limitations: Because it stores its data in memory, it is not suitable for extremely large data sets. 
      

  3.   

    public Collection getCars(String make,String model,double highprice)
    {
       List cars=new ArrayList();
       Connection conn=null;
       Statement st=null;
       ResultSet rs=null;
       try
      {
         conn=dataSource.getConnection();
         st=conn.createStatement();
         rs=st.executeQuery("select ake,model,year,color,mileage,"+
    "price,vin from "+tableName+" where price<="+highPrice+" and "+
    "model='"+model+"' and make='"+mak+"'");
         while(rs.next())
         {
           int year=rs.getInt(3);
           String color=rs.getString(4);
           int mileage=rs.getInt(5);
           double price-rs.getDouble(6);
           int vin=rs.getInt(7);
           cars.add(new CarValueObject(make,model,year,color,mileage,
    price,vin));
         }
         return cars;
       }
       catch(SQLException e)
      {
         e.printStarcTrace();
      }
      finally
      {
        if(rs!=null) try(rs.close();} catch(Exception ignore){}
        if(st!=null) try(st.close();} catch(Exception ignore){}
        if(conn!=null) try(conn.close();} catch(Exception ignore){}
      }
    }
      

  4.   

    请教 value object设计模式
      

  5.   

    俺觉得sunlightnh(陽光) (  ) 的方法好!
    CachedRowset的方法我很早就用过,因为它提供离线的结果及缓存,比较方便!对EJB来说,容易序列化!但它的缺电就是在客户端(或前端),一般是Jsp,Servlet不能显式表现返回内容。编程不方便!
    而采用定义对象,加入到数组的方法就可以避免这个问题!目前我在EJB开发中主要是采用这种方法!
      

  6.   

    俺都是用Value Object或者Value Object的集合作为ejb和client的传递容器不过有一点需要特别注意,复合的VO必须保证VO内所有内容都已序列化,否则,,嘿嘿,等着出彩吧。
      

  7.   

    请问楼上两位,请讲讲value object模式的使用及思路,好吗?本人这两天还没弄清楚这value object应怎样使用?我看在petstore里大概是这样调用的:定议一个bean,在bean里有相应的set,get方法,然而在local ejb(petstore 都是用local ejb)的create()里把数据bean.setXXX(),在EjbPostCreate()里bean.getXXX(),
    这就是value object方式吗?请教了。
    我是用struts1.1+ejb+weblogic7+jbuilder7开发,框架正建中,头痛中呀,请教了
      

  8.   

    CachedRowset用起来是不错,但还不是release版本,要考虑其可靠性;value object模式应该是不错的选择
      

  9.   

    data transfer object 和 value object 都是不错的选择。
    我以前用dto,现在用vo.
      

  10.   

    俺现在不用ejb,不过也up一下吧。
      

  11.   

    俺现在不用ejb,不过也up一下吧。