I'm running the jOOQ generation tool (jdk11+ trial version) and it generates correctly Java classes for each table, however the package includes the database name and the schema. I want to omit these two in the package. I'm running this on SQL Server 2022 Developer Edition.
java -classpath jooq-3.19.9.jar;jooq-meta-3.19.9.jar;jooq-codegen-3.19.9.jar;jakarta.xml.bind-api-3.0.0.jar;r2dbc-spi-1.0.0.RELEASE.jar;reactive-streams-1.0.3.jar;mssql-jdbc-12.6.2.jre11.jar;. org.jooq.codegen.GenerationTool ss.xml
It generates the package:
package dbmetab.bank_dd_0002.dbo.tables;
and I need the package to be:
package dbmetab.tables;
this is ss.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<configuration xmlns="http://www.jooq.org/xsd/jooq-codegen-3.11.0.xsd">
<!-- Configure the database connection here -->
<jdbc>
<driver>com.microsoft.sqlserver.jdbc.SQLServerDriver</driver>
<url>jdbc:sqlserver://;serverName=localhost;databaseName=bank_dd_0002;encrypt=false</url>
<user>abc</user>
<password>xxx</password>
</jdbc>
<generator>
<!-- The default code generator. You can override this one, to generate your own code style.
Supported generators:
- org.jooq.codegen.JavaGenerator
- org.jooq.codegen.ScalaGenerator
Defaults to org.jooq.codegen.JavaGenerator -->
<name>org.jooq.codegen.JavaGenerator</name>
<database>
<!-- The database type. The format here is:
org.util.[database].[database]Database -->
<name>org.jooq.meta.sqlserver.SQLServerDatabase</name>
<!-- The database schema (or in the absence of schema support, in your RDBMS this
can be the owner, user, database name) to be generated -->
<!-- All elements that are generated from your schema
(A Java regular expression. Use the pipe to separate several expressions)
Watch out for case-sensitivity. Depending on your database, this might be important! -->
<inputSchema>dbo</inputSchema>
<includes>
app_dates|dates|holidays|banks|bank_groups|bank_group_banks
</includes>
<!-- All elements that are excluded from your schema
(A Java regular expression. Use the pipe to separate several expressions).
Excludes match before includes, i.e. excludes have a higher priority -->
<excludes></excludes>
</database>
<target>
<!-- The destination package of your generated classes (within the destination directory) -->
<packageName>dbmetab</packageName>
<!-- The destination directory of your generated classes. Using Maven directory layout here -->
<directory>C:\appdir\src\main\java</directory>
</target>
</generator>
</configuration>
The manual section about mapping generated catalogs and schemas has an example showing how to map your source catalog and schema to the default catalog and schema:
<configuration>
<generator>
<database>
<inputCatalog>my_input_catalog</inputCatalog>
<outputCatalogToDefault>true</outputCatalogToDefault>
<inputSchema>my_input_schema</inputSchema>
<outputSchemaToDefault>true</outputSchemaToDefault>
</database>
</generator>
</configuration>
This will effectively omit their generation. You can also remove them from being rendered in your SQL queries at runtime.