-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JpaSpecificationExecutor.findBy inserts wrong limit/offset into SQL Query #3533
Comments
It's a bit weird but intentional, you should provide a failing test case if you think it's a bug. |
I'm sorry but there's no way that this was intentional. Here's the standalone reproducer project: https://github.com/MartinHaeusler/springDataLimitOffsetReproducer It contains a full setup with two JUnit tests. They pass using Spring Boot 3.2.5 and they fail in 3.3.1. |
FYI, There is a internal change since v3.3.0, it caused offset 1 instead 0 |
So... this change introduced the bug? |
I think it's an intentional breaking change, you could fix tests by using |
I could, but I think we can agree that this is the opposite of a clean API... The |
|
I don't really care about the background, this is a crystal clear regression bug. I even delivered a reproducer that showcases this. There's nothing left to discuss here as far as I'm concerned. |
@MartinHaeusler thank you for getting in touch - we'd like to remind you of our code of conduct and kindly ask you to respect everyone trying to help. As @quaff already mentioned, the change was intentional and is documented in the release wiki. |
I have a Spring Data JPA repository like this:
... and I'm using a Spring Data
Specification
object (i.e. criteria API) to query it like so in my service:My JUnit test calls this with
limit
of 100 and anoffset
of 0. If I enable Hibernate logging and look at the actual SQL queries being produced (PostGreSQL 15, if it matters), I get the following picture:.limit(...)
call.offset(...)
callApart from the Spring Data JPA version, the codebase was unchanged.
This is really bad news. In 3.2.5 (which I'm using currently) the limit was already off-by-one (it queries one row in addition to what the input parameter to
.limit(...)
says) but that flew under the radar. I started investigating today because said unit test started to fail after I attempted an upgrade to 3.3.1. Well it turns out: now theoffset(...)
is also off by 1.Finding this took me quite a while. I would highly appreciate a fix.
The text was updated successfully, but these errors were encountered: