Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[eclipselink-users] Named Native Query is not producing LIMIT based queries with setMaxResults

I'm hoping someone can help explain the native paging feature in
Eclipse Link. I am using the oracle platform, when I call
setFirstResult setMaxResults on a JPA Query the SQL that gets produced
and logged by EclipseLink contains the normal limit stuff with rownum.

However if I do the same thing, but produce my query by calling
createNamedQuery paging still works but the SQL that gets logged (and
maybe not even executed) isn't the LIMIT stuff, it just looks like the
regular ol' NativeNamedQuery. This is causing some issues for us since
we're trying to do some string processing on the SQL in order to
dynamically create a count query (minus the subselect limit/rownum).

So I have two questions:

1) How does this even work, since I don't see the LIMIT based query
being created, yet paging seems to still work. Yet with a JPA query
you can clearly see the LIMIT SQL being created/executed.

2) Is there an easier way to get the count from a query without having
to dynamically (or statically) creating the SQL?

Thanks!

./tch


Back to the top