Top Description Fields Constructors Methods
org.jooq

public Class SchemaMapping

extends Object
implements Serializable
Class Inheritance
All Implemented Interfaces
java.io.Serializable
Annotations
@Deprecated
forRemoval:true
since:2.0
Static Imports
org.jooq.impl.DSL.name, .DSL.schema, org.jooq.tools.StringUtils.isBlank, .StringUtils.isEmpty

Deprecated

for removal since 2.0.

- 2.0.5 - Use runtime configuration Settings instead

General mapping of generated artefacts onto run-time substitutes.

There are several use cases, when the run-time schema configuration may be different from the compile-time (or code-generation-time) schema configuration. Say, you develop a schema called DEV. It contains a table DEV.T. When you install your database on a productive system, you might have two schemata:

This can be achieved with the SchemaMapping, where you can map schemata and tables, for them to render different names at run-time, than at compile-time.

Author
Lukas Eder
Since
1.5.2, 1.6.0
See Also
https://sourceforge.net/apps/trac/jooq/wiki/Manual/ADVANCED/SchemaMapping

Field Summary

Modifier and TypeField and Description
private transient volatile Map<String, Catalog>
private final Configuration
private static final JooqLogger
private static volatile boolean
private transient volatile Map<String, Schema>
private transient volatile Map<String, Table<?>>

Constructor Summary

AccessConstructor and Description
public
SchemaMapping(Configuration configuration)

Construct a mapping from a Configuration object

Method Summary

Modifier and TypeMethod and Description
public void
add(String
The schema known at codegen time to be mapped
inputSchema
,
String
The schema configured at run time to be mapped
outputSchema
)

Add schemata to this mapping

public void
add(String
The schema known at codegen time to be mapped
inputSchema
,
Schema
The schema configured at run time to be mapped
outputSchema
)

Add schemata to this mapping

public void
add(Schema
The schema known at codegen time to be mapped
inputSchema
,
Schema
The schema configured at run time to be mapped
outputSchema
)

Add schemata to this mapping

public void
add(Schema
The schema known at codegen time to be mapped
inputSchema
,
String
The schema configured at run time to be mapped
outputSchema
)

Add schemata to this mapping

public void
add(Table<?>
The table known at codegen time to be mapped
inputTable
,
Table<?>
The table configured at run time to be mapped
outputTable
)

Add tables to this mapping

public void
add(final Table<?>
The table known at codegen time to be mapped
inputTable
,
final String
The table configured at run time to be mapped
outputTable
)

Add tables to this mapping

private final Map<String, Catalog>
private final Map<String, Schema>
private final Map<String, Table<?>>
private static void
public @Nullable Catalog
map(Catalog catalog)

public @Nullable Schema

Returns:

The configured schema
map
(Schema
The schema to be mapped
schema
)

Apply mapping to a given schema

public <R extends Record> @Nullable Table<R>

Returns:

The configured table
map
(Table<R>
The generated table to be mapped
table
)

Apply mapping to a given table

private final RenderMapping
private final boolean
matches(MappedCatalog c, String catalogName)

private final boolean
matches(MappedSchema s, String schemaName)

private final boolean
matches(MappedTable t, String tableName)

private final boolean
private final boolean
public void
setDefaultSchema(String schema)

Synonym for use(String).

public void
setSchemaMapping(Map<String, String> schemaMap)

Initialise SchemaMapping.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
public void
use(Schema
the default schema
schema
)

Set a schema as the default schema.

public void
use(String
the default schema
schemaName
)

Set a schema as the default schema.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

catalogsback to summary
private transient volatile Map<String, Catalog> catalogs
configurationback to summary
private final Configuration configuration
logback to summary
private static final JooqLogger log
loggedDeprecationback to summary
private static volatile boolean loggedDeprecation
schemataback to summary
private transient volatile Map<String, Schema> schemata
tablesback to summary
private transient volatile Map<String, Table<?>> tables

Constructor Detail

SchemaMappingback to summary
public SchemaMapping(Configuration configuration)

Construct a mapping from a Configuration object

Method Detail

addback to summary
public void add(String inputSchema, String outputSchema)

Add schemata to this mapping

Parameters
inputSchema:String

The schema known at codegen time to be mapped

outputSchema:String

The schema configured at run time to be mapped

addback to summary
public void add(String inputSchema, Schema outputSchema)

Add schemata to this mapping

Parameters
inputSchema:String

The schema known at codegen time to be mapped

outputSchema:Schema

The schema configured at run time to be mapped

addback to summary
public void add(Schema inputSchema, Schema outputSchema)

Add schemata to this mapping

Parameters
inputSchema:Schema

The schema known at codegen time to be mapped

outputSchema:Schema

The schema configured at run time to be mapped

addback to summary
public void add(Schema inputSchema, String outputSchema)

Add schemata to this mapping

Parameters
inputSchema:Schema

The schema known at codegen time to be mapped

outputSchema:String

The schema configured at run time to be mapped

addback to summary
public void add(Table<?> inputTable, Table<?> outputTable)

Add tables to this mapping

Parameters
inputTable:Table<?>

The table known at codegen time to be mapped

outputTable:Table<?>

The table configured at run time to be mapped

addback to summary
public void add(final Table<?> inputTable, final String outputTable)

Add tables to this mapping

Parameters
inputTable:Table<?>

The table known at codegen time to be mapped

outputTable:String

The table configured at run time to be mapped

getCatalogsback to summary
private final Map<String, Catalog> getCatalogs()
getSchemataback to summary
private final Map<String, Schema> getSchemata()
getTablesback to summary
private final Map<String, Table<?>> getTables()
logDeprecationback to summary
private static void logDeprecation()
mapback to summary
public @Nullable Catalog map(Catalog catalog)
Annotations
@Nullable
mapback to summary
public @Nullable Schema map(Schema schema)

Apply mapping to a given schema

Parameters
schema:Schema

The schema to be mapped

Returns:@Nullable Schema

The configured schema

Annotations
@Nullable
mapback to summary
public <R extends Record> @Nullable Table<R> map(Table<R> table)

Apply mapping to a given table

Parameters
table:Table<R>

The generated table to be mapped

Returns:@Nullable Table<R>

The configured table

Annotations
@SuppressWarnings:unchecked
@Nullable
mappingback to summary
private final RenderMapping mapping()
matchesback to summary
private final boolean matches(MappedCatalog c, String catalogName)
matchesback to summary
private final boolean matches(MappedSchema s, String schemaName)
matchesback to summary
private final boolean matches(MappedTable t, String tableName)
renderCatalogback to summary
private final boolean renderCatalog()
renderSchemaback to summary
private final boolean renderSchema()
setDefaultSchemaback to summary
public void setDefaultSchema(String schema)

Synonym for use(String). Added for better interoperability with Spring

setSchemaMappingback to summary
public void setSchemaMapping(Map<String, String> schemaMap)

Initialise SchemaMapping. Added for better interoperability with Spring

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override
useback to summary
public void use(Schema schema)

Set a schema as the default schema. This results in the supplied schema being omitted in generated SQL.

If the supplied mapping has already been added using add(Schema, Schema), then use() has no effect.

Parameters
schema:Schema

the default schema

useback to summary
public void use(String schemaName)

Set a schema as the default schema. This results in the supplied schema being omitted in generated SQL.

If the supplied mapping has already been added using add(Schema, Schema), then use() has no effect.

Parameters
schemaName:String

the default schema