Hi Ian,

The bottom of the documentation page suggested by Sergey indicates
another manual page, explaining how to hard-wire mappings at
code-generation time
http://www.jooq.org/doc/2.5/manual/sql-building/factory/runtime-schema-mapping/#N105ED

It links here:
http://www.jooq.org/doc/2.5/manual/code-generation/schema-mapping/

In your case, you would probably need different code generation
settings when code is generated from staging or production databases.
Note also that you can map several schemata (staging and production)
to a single one (staging or production).

Another option is to use a "default schema" at runtime:
http://www.jooq.org/doc/2.5/manual/sql-building/factory/runtime-schema-mapping/#N105C6

Or use the renderSchema flag from the runtime settings:
http://www.jooq.org/xsd/jooq-runtime-2.5.0.xsd

That way, you can tell jOOQ not to render any schema names in rendered
SQL. This will mean that you'll have to set the schema in your JDBC
connection, of course.

Hope this helps

Cheers
Lukas

2012/9/16 Ian Clarke <ian.cla...@gmail.com>:
> Thanks for the reply Sergey, but what if I don't know the schema name used
> in the generated code?  In our setup this varies depending on whether we're
> deploying to staging or production.
>
> Ian.
>
>
> On Wednesday, September 12, 2012 12:10:18 PM UTC-5, Sergey Epik wrote:
>>
>> Hello Ian,
>>
>> Take a look:
>>
>> http://www.jooq.org/doc/2.5/manual/sql-building/factory/runtime-schema-mapping/
>>
>> here is example:
>>
>>         Factory factory = new Factory(
>>                 transactionAwareDataSource(),
>>                 SQLDialect.ORACLE,
>>                 new Settings()
>>                         .withRenderMapping(new RenderMapping()
>>                                 .withSchemata(new MappedSchema()
>>                                         .withInput("PROJ")
>>                                         .withOutput("PROJ_PROD")))
>>         );
>>
>> where "PROJ" - is staging schema name (this name is used in generated
>> code).
>> "PROJ_PROD" - production schema
>>
>> --
>>
>> On Wed, Sep 12, 2012 at 7:32 PM, Ian Clarke <ian.c...@gmail.com> wrote:
>>>
>>> I asked this before I think but Jooq has had a few releases since then.
>>>
>>> How do I force Jooq to use a particular database schema (I'm using
>>> MySql), regardless of which schema was used to generate the sources?
>>>
>>> With our current setup, we generate sources from a staging or production
>>> schema, depending on whether it's our staging platform or our production
>>> code.
>>>
>>> But in one particular instance, I want my code to use the staging schema
>>> regardless of whether the sources were generated from our staging or
>>> production schema.
>>>
>>> Is this possible?
>>>
>>> Thanks,
>>>
>>> Ian.
>>>
>>> --
>>> Ian Clarke
>>> Blog: http://blog.locut.us/
>>>
>>
>

Reply via email to