I have a Spring Boot application and generating the code works fine from a
PostgreSQL database.
When running the Spring Boot integration tests I get an error message
saying that the schema 'public' doesn't exist.
I used 'public' as the inputSchema property during code generation (using
Gradle).
At runtime the application works as expected but during the integration
tests this doesn't work.
After some googling I came to this
http://www.jooq.org/doc/3.8/manual/sql-building/dsl-context/runtime-schema-mapping/
.
So I created a @Configuration class that has a @Primary annotated @Bean to
make sure that the new settings are applied. This is my configuration:
@Bean
@Primary
public org.jooq.Configuration config() {
org.jooq.Configuration config = new DefaultConfiguration();
config.set(SQLDialect.valueOf(sqlDialect));
config.set(connectionProvider);
config.set(new Settings().withRenderMapping(
new RenderMapping().withSchemata(
new MappedSchema().withInput("public").withOutput("")
)
));
config.set(new DefaultExecuteListenerProvider(
new DefaultExecuteListener() {
@Override
public void exception(ExecuteContext ctx) {
if (null != ctx.sqlException()) {
SQLDialect dialect = ctx.dialect();
SQLExceptionTranslator translator = (null != dialect
) ?
new SQLErrorCodeSQLExceptionTranslator(dialect.
thirdParty().springDbName()) :
new SQLStateSQLExceptionTranslator();
ctx.exception(translator.translate("jOOQ", ctx.sql
(), ctx.sqlException()));
}
}
}
));
return config;
}
In my tests I have the @Autowired DSLContext and during execution of the
tests I see in the properties of the DSLContext that the rendermapping is
used (see attached screenshot).
But somehow I get an Exception saying that the schema 'public' can't be
found.
<https://lh3.googleusercontent.com/-YfLcc2jHV6U/V-oSMNV7_CI/AAAAAAAAAps/VP-K4-T8_oY4vFEQF-FC9QYJf05VMN8tgCLcB/s1600/Screen%2BShot%2B2016-09-27%2Bat%2B08.11.58.png>
--
You received this message because you are subscribed to the Google Groups "jOOQ
User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.