Hibernate 5 Multitenancy and H2 : ERROR org.hibernate.engine.jdbc.spi.SqlExceptionHelper - Schema MYSCHEMA not found

回眸只為那壹抹淺笑 提交于 2020-06-29 04:43:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!