I agree.  This is not a Derby error.  Derby is just throwing the error because Hibernate, in this case, is trying to get a 3rd parameter when there are only two in the query.  Check that the (Hibernate) dialect is configured for Derby, and then ask this over on the Hibernate forums.

You can also enable trace logging for Hibernate (via log4j or whatever logging framework you use) and get a clue about the query generation from it's perspective.


On Wed, May 26, 2010 at 1:50 PM, Bryan Pendleton <bpendleton.derby@gmail.com> wrote:
This part:

> where product0_.lid=? and product0_.userVersion=? fetch first 2 rows

seems to match this part:

> cq.where(cb.and(cb.equal(lidAttr, lid), cb.equal(userVersionAttr, userVersion)));

pretty closely, so it's hard to imagine why your O/R tool thought it
needed to set 3 parameters in the query.

Unless it somehow thought it was trying to set the "first 2 rows" part? That is,
did it think it had prepared "fetch first ? rows" and was trying to set the 2?

You may need to ask in a forum that covers your O/R tool, to get some
suggestions about how to understand its query generation behaviors.
Did you say you were using Hibernate?

Regarding whether Derby is processing the statement twice, I think that
the log is just a bit hard to read: the statement is listed twice,
but once is a "begin compiling" trace, and once is an "end compiling" trace.

So, I'm afraid I don't have any breakthrough answers for you, but hopefully
you're armed with more information to ask a more specific question to the
providers of the O/R tool.