I have a moderate size project using Spring Boot, and I am trying to create my first DataJpaTest with embedded H2, but I am getting the following exception:
org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "drop table project.project.driver if exists" via JDBC Statemen
Caused by: org.h2.jdbc.JdbcSQLException: Schema "PROJECT" not found; SQL statement:
I have tried this and using a schema.sql, also this and using a test.properties in test/resources, and this other answer. But nothing worked. I am really baffled; this is the first time I face an issue in Spring Boot that I am not able to figure it out.
My entity classes are defined as:
@Entity
@Table(name = "table_name", schema = "project", catalog = "project")
@Lombok.Data
public class TableNameEntity { }
Any suggestion of how to force Hibernate to create the schema in H2?
You can pass a sql script which create schema in h2`s url:
jdbc:h2:mem:somedb;DB_CLOSE_DELAY=-1;INIT=RUNSCRIPT FROM 'classpath:create_schema.sql'
And in create_schema.sql would be something like this
CREATE SCHEMA IF NOT EXISTS project;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With