I'm trying to code a web-app using Spring-Boot, HSQLDB, Flyway and MyBatis. I started without MyBatis and Flyway happily created the database every time I had removed the HSQLDB.
After I added MyBatis all was fine until I had to make changes in the initial SQL-file and removed the database. Now I'm failing to start the web-app. It seems as if Flyway and MyBatis somehow depend on each other.
My database configuration:
@Configuration
public class DatabaseConfiguration {
@Bean
public DataSource dataSource() { ... }
@Bean
public DataSourceTransactionManager transactionManager() { ... }
@Bean
public static MapperScannerConfigurer mapperScannerConfigurer() { ... }
@Bean
public DataSourceInitializer dataSourceInitializer() throws Exception { ... }
@Bean
public SqlSessionFactoryBean sqlSessionFactoryBean() throws Exception { ... }
@Bean
public SqlSessionTemplate sqlSessionTemplate() throws Exception { ... }
}
I fully understand that MapperScannerConfigurer, SqlSessionFactoryBean and SqlSessionTemplate are coming from MyBatis, all Flyway-stuff is done by Spring-Boot. From what I can tell Flyway needs a DataSource and MyBatis needs a database where the Flyway scripts ran already to allow the initialisation of the mappers.
The error I get is
### Error querying database. Cause: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: MY_TABLE
### The error may exist in file [/home/work/Eclipse/com.sjngm.hs/target/classes/sqlmap/MyTableMapper.xml]
### The error may involve com.sjngm.hs.dao.mapper.MyTableMapper.getByName
### The error occurred while executing a query
### SQL: SELECT * FROM MY_TABLE WHERE Name = ?
### Cause: java.sql.SQLSyntaxErrorException: user lacks privilege or object not found: MY_TABLE
Note that there is no indication in the entire log-file that Flyway already did something. Also I can't find any CREATE TABLE in HSQLDB's files, which makes the above error saying that it can't find table MY_TABLE.
I already tried moving dataSource() to a new configuration class, but that didn't help.
What do I need to do to solve that indirect dependency?