I have several objects at my data level stored in a particular schema. For instance:
@Entity @Table(name = "FOO", schema = "DUMMY") public class Foo {}
I am trying to configure an embedded H2 database to test the integration of my data layer. I use the @DataJpaTest annotation for my tests to automatically configure the embedded H2 database. However, tables are not created because the DUMMY schema DUMMY not created during DB initialization.
Any ideas on how to create a schema before creating tables in test cases?
I tried using @Sql (statements = "CREATE SCHEMA IF NOT EXISTS DUMMY") but failed.
In addition, I tried to set spring.datasource.url = jdbc:h2:mem:test;INIT=CREATE SCHEMA IF NOT EXISTS DUMMY in my test.properties file along with TestPropertySource("classpath:test.properties") , but that too did not work.
source share