问题
I am using Spring Framework test configuration (legacy app)
Very strange behaviour of H2 database with Hibernate 5 multitenancy,
I just added configuration to my tests, and the spring application context can't work :
@Bean
public static DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.h2.Driver");
dataSource.setUrl("jdbc:h2:mem:db;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false");
dataSource.setUsername("sa");
dataSource.setPassword("");
return dataSource;
}
=> [main] ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper Schema "MYSCHEMA" not found [90079-197]
So i went with the usual H2 add schema.
@Bean
public static DataSource dataSource() {
DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("org.h2.Driver");
dataSource.setUrl("jdbc:h2:mem:db;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;INIT=CREATE SCHEMA MYSCHEMA");
dataSource.setUsername("sa");
dataSource.setPassword("");
return dataSource;
}
Schema "MYSCHEMA" already exists; SQL statement:
CREATE SCHEMA MYSCHEMA[90078-197]
And I'm now stuck... I already tried hbm2ddl to update, I'm actually very confused...
来源:https://stackoverflow.com/questions/62388000/hibernate-5-multitenancy-and-h2-error-org-hibernate-engine-jdbc-spi-sqlexcepti