On 1/20/2011 1:03 PM, Pavel Bortnovskiy wrote:
the more I am working through this issue, the more I get convinced that it's a Derby issue.
When the select statement is modified slightly (not using joining of tables on themselves, but rather using IN), then everything works without a hiccup:

SELECT
    P1.ID ,
    R1.description
    P1.BOOK
    P1.NOMINAL
    P1.NOMINAL * R1.Factor
FROM
    P_TABLE P1,
    R_TABLE R1
WHERE
    P1.IN_ID = R1.IN_ID  AND
    R1.IN_ID in (
      select
              R2.IN_ID
      from
              P_TABLE P2,
              R_TABLE R2
      where
              P2.IN_ID = R2.IN_ID AND
              P2.NOMINAL <> 0  AND
              R2.IType='X'
      GROUP BY R2.IN_ID
      HAVING COUNT(*) >1
    )


So, this leads me to believe that SELECT statements such as this causes a problem within Derby:

select
    *
from
    TABLE T1,
     (
         select <field> from TABLE T2
     ) as M
where
    M.<field> = T1.<field>

I think it would be worthwile to file an issue in Jira while you work to get a reproduction that the community can work with.  Put as much information as you can in the Jira issue especially useful would be a thread dump even if the proprietary parts are edited out.   You might also want to set lock timeout and deadlock timeout low [1] so that you don't have to wait for those errors if they are occurring.

Generally the more information you can provide the better the community will be able to help. As for it being urgent, once you get a reproduction and confirm it as a Derby issue, I think that you will find the development community very supportive if you want to try to fix it yourself.

Thanks

Kathey
[1] http://db.apache.org/derby/docs/10.7/devguide/cdevconcepts16400.html