-
Notifications
You must be signed in to change notification settings - Fork 40.8k
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
JdbcSQLSyntaxErrorException after upgrade to 3.3.0 #40940
Comments
I don't see the connection between the error that you're seeing and the question on Stack Overflow. The former is a problem reported by H2 when executing an SQL query. The latter is an error reported by Hibernate when parsing an HQL query. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue. |
I believe you are using wrong hibernate dialect because |
@quaff Indeed I'm using another dialect, as in production there's a This is the minimal sample you've asked for @wilkinsona , thank you for your swift and clear response! |
Thanks for the sample, I've reproduced the problem and observed that it does not occur when downgrading Hibernate to 6.4.8.Final:
This tells us that the change in behavior is due to a change in Hibernate 6.5. The SQL dialect for Postgres is generating different SQL and this SQL is now incompatible with H2 running in Postgres compatibility mode. With Hibernate 6.5, the SQL is the following:
With Hibernate 6.4, it's the following:
If it works fine with a real Postgres instance then this is arguably a bug in/limitation of H2's Postgres compatibility mode that Hibernate's changed SQL is triggering. If it doesn't work with a real Postgres instance then I think it's a Hibernate bug. Either way, I'm afraid that this is out of Spring Boot's control and will have to be dealt with by the maintainers of Hibernate or of H2. |
@Sax388 Why not let Hibernate choose the right dialect? IMO, you shouldn't specify dialect if the database is well-known. |
@quaff Thank you for your support. I didn't quite get you. I intentionally chose to use driverClassName: org.h2.Driver
url: jdbc:h2:mem:testdb;MODE=PostgreSQL;DEFAULT_NULL_ORDERING=HIGH;NON_KEYWORDS=VALUE to make it behave more like the well-known database in production (there were some issues, not detected by the tests before). We're only using H2 for our tests. I think it's time to ditch it and move on to using a full postgresql database e.g. inside testcontainers. What do you think? EDIT: I feel a little dumb now, but h2database/h2database#3962 (comment) told me there was a bad configuration right above the properties mentioned above. Without these it's actually working again. |
Sorry, I thought you are manually set hibernate dialect, It's EDIT: you are manually set hibernate dialect indirectly by |
@wilkinsona really appreciate your help. I was getting the exact same error on trying to insert data into a user table like the following: The problem was the "returning id". I just downgraded hibernate and overwrote the version from the one installed from spring jpa. It worked. Thanks again! |
With the upgrade from Spring Boot
3.2.6
to3.3.0
we're getting errors like these when running our tests on an H2 database:This could potentially be connected to https://stackoverflow.com/questions/78539828/spring-data-jpa-validation-fails-after-update-to-spring-boot-3-3-0.
The text was updated successfully, but these errors were encountered: