0 Replies Latest reply on Sep 25, 2003 9:16 AM by maggiegy

    Urgent!Pls pls help! simple question of EJB QL

    maggiegy

      Hello,

      I'm new learner on EJB and now I'm working on a project which need to use EJB QL. I went through the specification 2.0 of EJB QL released by Sun, I'm not quite understand the following words regarding to the SELECT clause of EJB QL:

      "In the case of a find method, the SELECT clause is restricted to contain either a single range variable or a single value path expression that evaluates to the abstract schema type of the entity bean for which the finder method is defined.
      Because finder method cannot return arbitrary types, the SELECT clause of an EJB QL defined for a finder method must always correspond to the abstract shcema type fo the entity bean for which the finder method is defined.In contrast, the SELECT clause of a query defined for a select method can return the abstract schema types of other entity beans or the values of cmp-fields."

      As my understanding, I think the SELECT clause of finder method can only contain a single range variable instead of single value path expresson, it should have only one format, which is "SELECT [DISTINCT] OBJECT(identification_variable)".

      For example: the query below is defined in OrderBean findByProductType();
      SELECT OBJECT(o) FROM Order o, IN(o.lineItems) l
      WHERE l.product.product_type = 'schoolsupplies'

      how it could be a single value path expression , I think this format can only be used in Select method.

      I don't know if I'm correct or not. I'd appreciate if anybody can help me with this.

      Thanks!
      Maggie