Using a Spring DataSource and a QueryDsl SQLQueryImpl, how do you specify the schema or set the schema?
Test case is:
- Use querydsl-maven-plugin (2.9.0) to connect to DB2 database to generate Q-Classes specifying
<schemaPattern> - Spring creates a
DataSourcebean DataSourcebean is populated by scripts (CREATE SCHEMA FOO,CREATE TABLE FOO.BARetc)- JUnit test imports
DataSource - Query using
new SQLQueryImpl(dataSource.getConnection(), Configuration.DEFAULT)
Error:
org.h2.jdbc.JdbcSQLException: Table "BAR" not found; SQL Statement: ...
Note that this test implementation is an H2 database, but the production database is DB2. So far I’ve tried specifying the schema in the JDBC connection strings to no avail.
I was able to extend
SQLTemplateswith my own implementation that called the protected methodsetPrintSchema(true);.