3 Replies Latest reply on Jul 18, 2004 4:30 PM by Joachim Van der Auwera

    Strange sql query generated from findAll ejbQL.

    jlmcknight Newbie

      Running JBoss 3.2.3 with an Oracle 8 database, I've defined a findAll EJBQL to get all rows from a table:

      SELECT OBJECT(f) FROM FOO AS f

      Then when I execute it, I see this:

      Executing SQL: SELECT t0_f.KEY1, t0_f.KEY2 FROM FOO t0_f

      But, then when I begin iterating through the returned collection, when I
      make the first getter method call, it executes the query below, apparently to populate all of the entities:

      Executing SQL: SELECT KEY1, KEY2, DATE, ORDER, TITLE, CODE FROM FOO
      WHERE (KEY1=? AND KEY2=?)
      OR (KEY1=? AND KEY2=?)
      OR (KEY1=? AND KEY2=?)
      OR (KEY1=? AND KEY2=?)
      OR (KEY1=? AND KEY2=?)
      OR (KEY1=? AND KEY2=?)
      OR (KEY1=? AND KEY2=?)
      OR (KEY1=? AND KEY2=?)
      OR (KEY1=? AND KEY2=?)
      OR (KEY1=? AND KEY2=?)

      I have several entites/tables, and it does this on each, apparently building an OR block for every row/key in the table (thousands in some cases), which is hanging the Oracle server. Why is it contructing the query like this, rather than as a simple:

      SELECT KEY1, KEY2, DATE, ORDER, TITLE, CODE FROM FOO

      Any ideas how to fix this?

      Thanks,
      Jason