public final class Configuration
extends java.lang.Object
| Constructor and Description |
|---|
Configuration(SQLTemplates templates)
Create a new Configuration instance
|
| Modifier and Type | Method and Description |
|---|---|
void |
addListener(SQLListener listener)
Add a listener
|
java.lang.String |
asLiteral(java.lang.Object o)
Get the literal representation of the given constant
|
<T> T |
get(java.sql.ResultSet rs,
@Nullable Path<?> path,
int i,
java.lang.Class<T> clazz)
Get the value at the given index from the result set
|
java.lang.String |
getColumnOverride(SchemaAndTable key,
java.lang.String column)
Get the column override
|
java.lang.Class<?> |
getJavaType(int sqlType,
java.lang.String typeName,
int size,
int digits,
java.lang.String tableName,
java.lang.String columnName)
Get the java type for the given jdbc type, table name and column name
|
SQLListeners |
getListeners()
Get the registered listener
|
@Nullable SchemaAndTable |
getOverride(SchemaAndTable key)
Get the schema/table override
|
SQLTemplates |
getTemplates() |
java.lang.String |
getTypeName(java.lang.Class<?> type)
Get the SQL type name for the given java type
|
java.lang.String |
getTypeNameForCast(java.lang.Class<?> type)
Get the SQL type name for a cast operation
|
boolean |
getUseLiterals()
Get whether literals are serialized or prepared statement bindings are used
|
void |
register(java.lang.String table,
java.lang.String column,
java.lang.Class<?> javaType)
Register the given javaType for the given table and column
|
void |
register(java.lang.String table,
java.lang.String column,
Type<?> type)
Register the given
Type converter for the given table and column |
void |
register(Type<?> type)
Register the given
Type converter |
java.lang.String |
registerColumnOverride(java.lang.String table,
java.lang.String oldColumn,
java.lang.String newColumn)
Deprecated.
Use
setDynamicNameMapping(NameMapping) instead. |
java.lang.String |
registerColumnOverride(java.lang.String schema,
java.lang.String table,
java.lang.String oldColumn,
java.lang.String newColumn)
Deprecated.
Use
setDynamicNameMapping(NameMapping) instead. |
void |
registerNumeric(int total,
int decimal,
java.lang.Class<?> javaType)
Override the binding for the given NUMERIC type
|
void |
registerNumeric(int beginTotal,
int endTotal,
int beginDecimal,
int endDecimal,
java.lang.Class<?> javaType)
Override multiple numeric bindings, both begin and end are inclusive
|
java.lang.String |
registerSchemaOverride(java.lang.String oldSchema,
java.lang.String newSchema)
Deprecated.
Use
setDynamicNameMapping(NameMapping) instead. |
SchemaAndTable |
registerTableOverride(SchemaAndTable from,
SchemaAndTable to)
Deprecated.
Use
setDynamicNameMapping(NameMapping) instead. |
java.lang.String |
registerTableOverride(java.lang.String oldTable,
java.lang.String newTable)
Deprecated.
Use
setDynamicNameMapping(NameMapping) instead. |
java.lang.String |
registerTableOverride(java.lang.String schema,
java.lang.String oldTable,
java.lang.String newTable)
Deprecated.
Use
setDynamicNameMapping(NameMapping) instead. |
SchemaAndTable |
registerTableOverride(java.lang.String schema,
java.lang.String oldTable,
java.lang.String newSchema,
java.lang.String newTable)
Deprecated.
Use
setDynamicNameMapping(NameMapping) instead. |
void |
registerType(java.lang.String typeName,
java.lang.Class<?> clazz)
Register a typeName to Class mapping
|
<T> void |
set(java.sql.PreparedStatement stmt,
Path<?> path,
int i,
T value)
Set the value at the given index in the statement
|
void |
setDynamicNameMapping(NameMapping nameMapping)
Programmers can specify name mappings by implementing the
NameMapping interface. |
void |
setExceptionTranslator(SQLExceptionTranslator exceptionTranslator)
Set the exception translator
|
void |
setTemplates(SQLTemplates templates)
Set the templates to use for serialization
|
void |
setUseLiterals(boolean useLiterals)
Set whether literals are used in SQL strings instead of parameter bindings (default: false)
|
java.lang.RuntimeException |
translate(java.sql.SQLException ex)
Translate the given SQLException
|
java.lang.RuntimeException |
translate(java.lang.String sql,
java.util.List<java.lang.Object> bindings,
java.sql.SQLException ex)
Translate the given SQLException
|
public Configuration(SQLTemplates templates)
templates - templates for SQL serializationpublic java.lang.String asLiteral(java.lang.Object o)
o - objectpublic SQLTemplates getTemplates()
public java.lang.Class<?> getJavaType(int sqlType,
java.lang.String typeName,
int size,
int digits,
java.lang.String tableName,
java.lang.String columnName)
sqlType - JDBC typetypeName - JDBC type namesize - sizedigits - digitstableName - table namecolumnName - column name@Nullable
public <T> T get(java.sql.ResultSet rs,
@Nullable
@Nullable Path<?> path,
int i,
java.lang.Class<T> clazz)
throws java.sql.SQLException
T - type to returnrs - result setpath - pathi - one based index in result set rowclazz - typejava.sql.SQLException@Nullable public @Nullable SchemaAndTable getOverride(SchemaAndTable key)
key - schema and tablepublic java.lang.String getColumnOverride(SchemaAndTable key, java.lang.String column)
key - schema and tablecolumn - columnpublic void setDynamicNameMapping(NameMapping nameMapping)
NameMapping interface. The mapping rules that are specified by
this property are checked if no mapping is specified by any of the
register*Override functions.nameMapping - The name mapping that is implemented by the user.public <T> void set(java.sql.PreparedStatement stmt,
Path<?> path,
int i,
T value)
throws java.sql.SQLException
T - stmt - statementpath - pathi - one based index in statementvalue - value to bindjava.sql.SQLExceptionpublic java.lang.String getTypeName(java.lang.Class<?> type)
type - java typepublic java.lang.String getTypeNameForCast(java.lang.Class<?> type)
type - java type@Deprecated
public java.lang.String registerSchemaOverride(java.lang.String oldSchema,
java.lang.String newSchema)
setDynamicNameMapping(NameMapping) instead.oldSchema - schema to overridenewSchema - override@Deprecated
public java.lang.String registerTableOverride(java.lang.String oldTable,
java.lang.String newTable)
setDynamicNameMapping(NameMapping) instead.oldTable - table to overridenewTable - override@Deprecated
public java.lang.String registerTableOverride(java.lang.String schema,
java.lang.String oldTable,
java.lang.String newTable)
setDynamicNameMapping(NameMapping) instead.schema - schema of tableoldTable - table to overridenewTable - override@Deprecated public SchemaAndTable registerTableOverride(java.lang.String schema, java.lang.String oldTable, java.lang.String newSchema, java.lang.String newTable)
setDynamicNameMapping(NameMapping) instead.schema - schema of tableoldTable - table to overridenewSchema - override schemanewTable - override table@Deprecated public SchemaAndTable registerTableOverride(SchemaAndTable from, SchemaAndTable to)
setDynamicNameMapping(NameMapping) instead.from - schema and table to overrideto - override@Deprecated
public java.lang.String registerColumnOverride(java.lang.String schema,
java.lang.String table,
java.lang.String oldColumn,
java.lang.String newColumn)
setDynamicNameMapping(NameMapping) instead.schema - schematable - tableoldColumn - columnnewColumn - override@Deprecated
public java.lang.String registerColumnOverride(java.lang.String table,
java.lang.String oldColumn,
java.lang.String newColumn)
setDynamicNameMapping(NameMapping) instead.table - tableoldColumn - columnnewColumn - overridepublic void register(Type<?> type)
Type convertertype - typepublic void registerType(java.lang.String typeName,
java.lang.Class<?> clazz)
typeName - SQL type nameclazz - java typepublic void registerNumeric(int total,
int decimal,
java.lang.Class<?> javaType)
total - total amount of digitsdecimal - amount of fractional digitsjavaType - java typepublic void registerNumeric(int beginTotal,
int endTotal,
int beginDecimal,
int endDecimal,
java.lang.Class<?> javaType)
beginTotal - inclusive start of rangeendTotal - inclusive end of rangebeginDecimal - inclusive start of rangeendDecimal - inclusive end of rangejavaType - java typepublic void register(java.lang.String table,
java.lang.String column,
java.lang.Class<?> javaType)
table - tablecolumn - columnjavaType - java typepublic void register(java.lang.String table,
java.lang.String column,
Type<?> type)
Type converter for the given table and columntable - tablecolumn - columntype - typepublic java.lang.RuntimeException translate(java.sql.SQLException ex)
ex - SQLException to translatepublic java.lang.RuntimeException translate(java.lang.String sql,
java.util.List<java.lang.Object> bindings,
java.sql.SQLException ex)
sql - SQL stringbindings - bindingsex - SQLException to translatepublic void addListener(SQLListener listener)
listener - listenerpublic SQLListeners getListeners()
public boolean getUseLiterals()
public void setUseLiterals(boolean useLiterals)
Warning: When literals are used, prepared statement won't have any parameter bindings and also batch statements will only be simulated, but not executed as actual batch statements.
useLiterals - true for literals and false for bindingspublic void setExceptionTranslator(SQLExceptionTranslator exceptionTranslator)
exceptionTranslator - exception translatorpublic void setTemplates(SQLTemplates templates)
templates - templatesCopyright © 2007–2021 Querydsl. All rights reserved.