1 Reply Latest reply on Feb 20, 2004 9:58 PM by aloubyansky

    EJB-QL: get a SET of Beans ???

    ericmacau

      Hello,

      How can I get a BEAN its ID is the MAXMIMUM ?


      For example,

      UserBean.java
      - userID
      - userName


      How can I retrieve the last User Object ?????

      signature="User findLastUser()"
      query=" ??????? "


      What should be defined in the query ???


      Eric

        • 1. Re: EJB-QL: get a SET of Beans ???
          aloubyansky

          Neither EJBQL nor JBossQL supports GROUP BY. In CMP2.0 EJBQL does not support even MAX.

          Possible queries:

          SELECT OBJECT(o) FROM B o ORDER BY o.id DESC LIMIT 1

          Otherwise

          SELECT MAX(o.id) FROM B o
          SELECT OBJECT(o) FROM B o WHERE o.id = ?1

          You have to use JBossQL in both cases.