Hello Lukas,

1. Can you explain what <expressions>(?i:(.*?.)?T_BOOLEANS.(VC|C|N)_BOOLEAN)</expressions> is trying to do?

2. I'm a bit confused about schema names. Presently we connect to the database with the db owner and use Apache Torque which generates SQL WITHOUT prefixing the table names with schema names. So we don't have to know the schema names like 'Public' in PG and 'dbo' (I guess) in SQL Server.
a) I've been able to run the GenerateTask with the following config.

<generate-classes
      jdbcdriver="org.postgresql.Driver"
      jdbcurl="jdbc:postgresql://localhost:5432/mydb?protocolVersion=2"
      jdbcuser="dbuser"
      jdbcpassword=""
      jdbcschema="public"
      generatordatabase="org.jooq.util.postgres.PostgresDatabase"
      generatordatabaseinputschema=""
      generatordatabaseoutputschema=""
      generatortargetpackage="com.mycompany.jooq"
      generatortargetdirectory="${src.java.dir}"/>

Seems like here the InputSchema is empty. But I'm specifying the jdbcschema. Can you explain the difference? The generated code works.

b) When I call
new Factory(connection, dialect,
    new Settings().withRenderMapping(
    new RenderMapping().withDefaultSchema("")));
I'm hoping that JOOQ will not prefix the table names with any schema name and that the default schema for the user connected would be used. Again, the purpose is to not concern ourselves with the schema name at all.

3) Regarding logging, log4j.properties is on the classpath and I've added log4j.logger.org.jooq=DEBUG. Our log statements are coming through but not JOOQ's. What am I missing?

Thanks again for your help,
- Ravi

On Sunday 08 April 2012 05:44 PM, Lukas Eder wrote:
Hello Ravi,

1. The example for<forcedType>  parameter uses column names to do the
mapping. Is there a way to indicate that a data type (e.g CHAR(1)) should be
mapped to a Boolean?
This is possible with some experimental code generation functionality.
It is not yet documented, however. You can use<forcedType/>  to force
a SQL data type upon a set of columns. The following example is from
the jOOQ integration tests::

<forcedType>
     <!-- Use a valid Postgres SQL type here, when generating from Postgres -->
     <name>BOOLEAN</name>
     <!-- All objects matching this regular expression will be forced
to type BOOLEAN -->
     <expressions>(?i:(.*?.)?T_BOOLEANS.(VC|C|N)_BOOLEAN)</expressions>
</forcedType>
2. Can I specify custom data mapping using the ANT task or can I invoke the
ANT task with a jooq-config.xml file?
The org.jooq.util.GenerationTask ant task is not up to date with the
latest developments of jooq-codegen. I recommend running the
GenerationTool using ant's<java/>  task, as documented here:
http://www.jooq.org/manual/META/Configuration/

3. Is it possible to not specify the schema name at all? I tried the
following with Postgres and it worked. Haven't tried it with SQL
Server/Oracle yet.

new Factory(connection, dialect,
    new Settings().withRenderMapping(
    new RenderMapping().withDefaultSchema("")));
This would have no effect on generated SQL. What are you trying to do?

4. How do I set up JOOQ logging? e.g to see the SQL statements it is
generating? We use log4j.
The default for Settings.isExecuteLogging() is true, so jOOQ already
logs all rendered SQL to log4j's debug log output. This is done using
the org.jooq.tools.LoggerListener, which supports log4j, slf4j, and
java.util.logging. If you need more information, you can set up your
own ExecuteListener, as documented here:
http://www.jooq.org/manual/ADVANCED/ExecuteListener/

A sample log4j configuration can be found here:
https://github.com/lukaseder/jOOQ/blob/master/jOOQ-test/src/log4j.xml

Hope this helps

Cheers
Lukas

Reply via email to