3 Replies Latest reply on Jul 4, 2002 11:47 AM by dsundstrom

    ejbSelectInEntity

    gchini

      Does Jboss 3.0 support ejbSelectInEntity methods??
      I have problems trying with a select that return one instance of an Entity in a One to Many relationship.

      This EJB-QL deploying gives me errors:
      select l from l in comComuneSt WHERE l.dataIni < ?1 AND (l.dataEnd > ?1 OR l.dataEnd IS NULL)
      where comComuneSt is a CMR field of the One to Many relationship
      while this seems to work:
      SELECT OBJECT(l) FROM ComComune AS c, IN (c.comComuneSt) As l WHERE l.dataIni < ?1 AND (l.dataEnd > ?1 OR l.dataEnd IS NULL)

      but returns all ComComuneSt related with any ComComune, not only with the current instance.

      Someone can help me??

        • 1. Re: ejbSelectInEntity
          dsundstrom

          > select l
          > from l in comComuneSt
          > WHERE l.dataIni < ?1 AND
          > (l.dataEnd > ?1 OR l.dataEnd IS NULL)

          This is not legal EJB-QL. The SELECT and FROM clauses are wrong.

          > SELECT OBJECT(l)
          > FROM ComComune AS c, IN (c.comComuneSt) As l
          > WHERE l.dataIni < ?1 AND
          > (l.dataEnd > ?1 OR l.dataEnd IS NULL)
          >
          > but returns all ComComuneSt related with any
          > ComComune, not only with the current
          > instance.

          EJB-QL queries have no concept of the current instance. If you want only ones for the curent instance you will need to pass in the current instance as a parameter and add something like "AND c = ?2" to the WHERE clause. When passing in the parameter make sure not to pass just "this" you need either the remote interface or the local interface which you can get from the EntityContext. Also the type of the parameter must be the remote or local interface you are passing in.

          • 2. Re: ejbSelectInEntity
            gchini

            Ok, but the Sun EJB Specification version 2.0 page 165 tells about the ejbSelect<METHOD_NAME>InEntity.
            But i never saw it in other books.

            • 3. Re: ejbSelectInEntity
              dsundstrom

              I searched the EJB 2.0 final draft and only found one entry in the Document Revsion History section E.10:

              Removed ejbSelectInEntity methods.

              I think you may have accidently grabbed an old copy of the specification.