Using a Spring DataSource
and a QueryDsl SQLQueryImpl
, how do you specify the schema or set the schema?
Test case is:
<schemaPattern>
DataSource
bean DataSource
bean is populated by scripts ( CREATE SCHEMA FOO
, CREATE TABLE FOO.BAR
etc) DataSource
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.
com.mysema.query.sql.SQLTemplates
has a builder method called printSchema()
. Initialise SQLTemplates
using the builder()
method and call printSchema()
before build()
. Example to follow:
SQLTemplates templates = OracleTemplates.builder().printSchema().build();
The Schema is encoded in the Q-types. It is accessed in the SQL serialization via the RelationalPath interface http://www.querydsl.com/static/querydsl/2.9.0/apidocs/com/mysema/query/sql/RelationalPath.html
I was able to extend SQLTemplates
with my own implementation that called the protected method setPrintSchema(true);
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.