3 Replies Latest reply on May 2, 2004 1:34 PM by sesques

    Basic question about ejb-ql query

    Julien Martin Expert

      I am running into the following problem:

      One of the parameters of my finder method is a collection. Here is my finder method:

      public Collection findEstablishments(String category, List postcodes, String name, Boolean commentsExist, Integer minNote, String sortOrderCriterion) throws FinderException;
      


      The behavior I want to achieve is as follows:
      -A collection of postcodes comme from the web tier e.g. (75001, 75004 and 75019)
      -The search should return all ejbs whose postcodes are either 75001, 75004 or 75019

      How does this translate into ejb-ql?

      Thanks in advance,

      Julien Martin.

        • 1. Re: Basic question about ejb-ql query
          sesques Novice

          Hi Julien,

          It is not possible to pass an array, ot a list or a collection to a finder query. I tried also with JBOSS-QL but same result.
          If you find a solution, I'm very interrested.

          Pascal

          • 2. Basic question about ejb-ql query
            Julien Martin Expert

            Hello Pascal,

            Perhaps the fact that it is not possible to deal with a collection in an ejb-ql query explains why it it not possible to pass a collection as an argument to an finder method. That looks like a serious limitation but a logical one. I think I am going to turn to plain JDBC and forget the finder methods for now.

            I'll keep you posted if I have an idea.

            Thanks,

            Julien.

            • 3. Re: Basic question about ejb-ql query
              sesques Novice

              Hi Julien,

              I agree that the EJB spec have limitations, and not only a few. But for this subject, we must think that even in SQL it is not possible. The only way to do that is to have theses elements (the list) in a table (temporary or not).
              We cannot pass a collection or a list as parameter in SQL or a stored procedure. Eventually, we can pass a String with all the elements (separated by a comma for exemple) and parse it to build a temporary table and then use this table as a filter in a subquery.

              But if you have an idea, it will be welcome

              Pascal