ejbSelect()在实体Bean内部是一种辅助方法来访问数据库,并不在Home接口中或者组件接口中向用户公开,容器将会自动在ejbSelect()方法中生成代码。关于它的调用,他不能在远程接口和本地接口调用,但是可以在商务方法中调用,这才是它和ejbFind的区别,但它们是用同样的方式告诉容器是怎么编写的

解决方案 »

  1.   

    你是在EJB-QL中告诉容器怎么来实现Select方法的吗,如果这样的话就容易了
    <query>
    <query-method>
    <method-name>ejbSelectxxx</method-name>
    ...
    ...
    </query-method>然后在你的方法中,用Collection  c = this.ejbSelectxxx();就可以得到select的结果如果你用工具生成代码的话,就想生成find方法一样,定义你的select方法,就可以了,用的时候方法是一样的
      

  2.   

    public abstract java.util.Collection ejbSelectid() throws FinderException ;这是我写的ejbselect()方法。“SELECT c.stuid FROM Student c”这是ejb-ql语句,是查表中的一列。
    下面是我得在另一个方法中的调用:
      public void selectID() throws Exception {
        Collection c=this.ejbSelectid() ;
        try{
          Iterator i=c.iterator();
      while(i.hasNext())
      {System.out .println(i.toString() );
      }
        }
        catch(Exception e){};
        /**@todo Complete this method*/
      }
      

  3.   

    但是有错误,我是用jb9.0做的,错误如下:
    "y2.jar": <2004-10-12 下午16时37分21秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: Student has a class y2.StudentBean that is in the classpath. This class should only be located in the ejb-jar file.> 
    "y2.jar": <2004-10-12 下午16时37分22秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: Student has a class y2.StudentRemoteHome that is in the classpath. This class should only be located in the ejb-jar file.> 
    "y2.jar": <2004-10-12 下午16时37分22秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: Student has a class y2.StudentRemote that is in the classpath. This class should only be located in the ejb-jar file.> 
    "y2.jar": <2004-10-12 下午16时37分22秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: Student has a class y2.StudentHome that is in the classpath. This class should only be located in the ejb-jar file.> 
    "y2.jar": <2004-10-12 下午16时37分22秒 CST> <Warning> <EJB> <BEA-010054> <EJB Deployment: Student has a class y2.Student that is in the classpath. This class should only be located in the ejb-jar file.> 
    "y2.jar": [J2EE:160121]Errors encountered while compiling module 'D:\javawork\y2\y2.jar.jar':
    "y2.jar": In EJB Student, the throws clause for method selectID() in the bean class contains exceptions that are NOT in the throws clause of the remote interface.
    请楼上的高手指点。
      

  4.   

    你把selectID()改成ejbSelectID()看看