getting this exception after updating to hibernate 6.x.x and spring boot 3.x.x
org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement [Table "table_name" not found; SQL statement:
application.properties
spring.datasource.driverClassName=org.h2.Driver
spring.jpa.database-platform=org.hibernate.dialect.H2Dialect
spring.datasource.url=jdbc:h2:mem:testservice;MODE=PostgreSQL;DATABASE_TO_LOWER=TRUE;CASE_INSENSITIVE_IDENTIFIERS=TRUE
spring.datasource.username=sa
spring.datasource.password=
spring.jpa.hibernate.naming.implicit-strategy=org.hibernate.boot.model.naming.ImplicitNamingStrategyComponentPathImpl
spring.jpa.hibernate.naming.physical-strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.H2Dialect
beikov
2
Well, you seem to be missing a table named table_name
. What is it that you don’t understand?
Hi. The entity is annotated with @Table(name = “table_name”). it was working with these configs before updating
@Entity
@Table(name = table_name, indexes = {
@Index(name = "serial_id_index", columnList = SERIAL_ID_COLUMN),
@Index(name = "customer_id_index", columnList = "customer_id")
})
beikov
4
There are so many possible reasons for such a problem. Please try to create a reproducer with our test case template (hibernate-test-case-templates/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java at main · hibernate/hibernate-test-case-templates · GitHub) and if you are able to reproduce the issue, create a bug ticket in our issue tracker(https://hibernate.atlassian.net) and attach that reproducer.
I found the problem. the MAX_FIELD_LENGTH = 10 * 1024 * 1024
was the problem.
@Column(length = MAX_FIELD_LENGTH, nullable = true)
private String aField;