Comments (7)
Thanks for the sample, I've reproduced the problem and observed that it does not occur when downgrading Hibernate to 6.4.8.Final:
ext['hibernate.version'] = "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:
insert into report_config (period_type) values (?) returning id
With Hibernate 6.4, it's the following:
insert into report_config (period_type) values (?)
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.
from spring-boot.
@quaff Indeed I'm using another dialect, as in production there's a
postgresql
database and I need it to be as close to this as possible. With Spring Boot3.2.6
everything was fine. I followed the migration guide for Hibernate6.5
but both resolutions found there still produce the error mentioned above. I got there through the release notes link.This is the minimal sample you've asked for @wilkinsona , thank you for your swift and clear response! https://github.com/Sax388/sql-h2-postgres-error-on-upgrade-to-spring-3.3.0
@Sax388 Why not let Hibernate choose the right dialect? IMO, you shouldn't specify dialect if the database is well-known.
from spring-boot.
@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=VALUEto 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 MODE=PostgreSQL
in jdbc url make hibernate detect H2 as PostgreSQL, I would like suggest you use H2 for unit tests and introduce testcontainers to use real PostgreSQL in integration tests.
EDIT: you are manually set hibernate dialect indirectly by spring.jpa.database=postgresql
, not caused by MODE=PostgreSQL
.
from spring-boot.
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.
from spring-boot.
I believe you are using wrong hibernate dialect because H2Dialect
will not generate unsupported sql like ... returning id
.
from spring-boot.
@quaff Indeed I'm using another dialect, as in production there's a postgresql
database and I need it to be as close to this as possible. With Spring Boot 3.2.6
everything was fine. I followed the migration guide for Hibernate 6.5
but both resolutions found there still produce the error mentioned above. I got there through the release notes link.
This is the minimal sample you've asked for @wilkinsona , thank you for your swift and clear response!
https://github.com/Sax388/sql-h2-postgres-error-on-upgrade-to-spring-3.3.0
from spring-boot.
@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.
from spring-boot.
Related Issues (20)
- Upgrade to Spring Pulsar 1.1.2
- Upgrade to Spring Pulsar 1.1.2
- Upgrade to H2 2.3.230
- little suggestion about ssl util PemContent
- Proposal for Content Revision on Wiki - "Spring Boot 3.0 Migration Guide" HOT 1
- Some @ControllerEndpoint and @RestControllerEndpoint infrastructure remains undeprecated
- Allow ContainerConnectionDetailsFactory to match on one of multiple different connection names
- Spring Authorization Server now defaults multipleIssuersAllowed to false and it cannot be easily re-enabled
- Exceeding 32 @SpringBootTest Configurations Causes Netty RejectedExecutionException with WebFlux HOT 3
- Fix documentation links in the README
- Fix documentation links in the README
- Add support for CNB platform API version 0.14
- Constructor binding of EnumMap fails due to missing key type HOT 2
- DynamicPropertyRegistry Values Not Set After Dev Tools Reload for RestartScope Containers
- Upgrade to Spring RESTDocs 3.0.2
- Upgrade to Spring Framework 6.2.0-M6
- Spring Boot 2 datasource can not run with Dockerfile HOT 4
- ClassNotFoundException in JSP compiler after update from Spring Boot 3.3.1 -> 3.3.2 HOT 6
- Broken documentation links HOT 2
- java.lang.LinkageError: loader 'app' attempted duplicate class definition for jakarta.persistence.TemporalType HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from spring-boot.