public final class Configuration extends 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
|
String |
asLiteral(Object o)
Get the literal representation of the given constant
|
<T> T |
get(ResultSet rs,
Path<?> path,
int i,
Class<T> clazz)
Get the value at the given index from the result set
|
String |
getColumnOverride(SchemaAndTable key,
String column)
Get the column override
|
Class<?> |
getJavaType(int sqlType,
String typeName,
int size,
int digits,
String tableName,
String columnName)
Get the java type for the given jdbc type, table name and column name
|
SQLListeners |
getListeners()
Get the registered listener
|
SchemaAndTable |
getOverride(SchemaAndTable key)
Get the schema/table override
|
SQLTemplates |
getTemplates() |
String |
getTypeName(Class<?> type)
Get the SQL type name for the given java type
|
String |
getTypeNameForCast(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(String table,
String column,
Class<?> javaType)
Register the given javaType for the given table and column
|
void |
register(String table,
String column,
Type<?> type)
Register the given
Type converter for the given table and column |
void |
register(Type<?> type)
Register the given
Type converter |
String |
registerColumnOverride(String table,
String oldColumn,
String newColumn)
Register a column override
|
String |
registerColumnOverride(String schema,
String table,
String oldColumn,
String newColumn)
Register a column override
|
void |
registerNumeric(int total,
int decimal,
Class<?> javaType)
Override the binding for the given NUMERIC type
|
void |
registerNumeric(int beginTotal,
int endTotal,
int beginDecimal,
int endDecimal,
Class<?> javaType)
Override multiple numeric bindings, both begin and end are inclusive
|
String |
registerSchemaOverride(String oldSchema,
String newSchema)
Register a schema override
|
SchemaAndTable |
registerTableOverride(SchemaAndTable from,
SchemaAndTable to)
Register a schema specific table override
|
String |
registerTableOverride(String oldTable,
String newTable)
Register a table override
|
String |
registerTableOverride(String schema,
String oldTable,
String newTable)
Register a schema specific table override
|
SchemaAndTable |
registerTableOverride(String schema,
String oldTable,
String newSchema,
String newTable)
Register a schema specific table override
|
void |
registerType(String typeName,
Class<?> clazz)
Register a typeName to Class mapping
|
<T> void |
set(PreparedStatement stmt,
Path<?> path,
int i,
T value)
Set the value at the given index in the statement
|
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
|
RuntimeException |
translate(SQLException ex)
Translate the given SQLException
|
RuntimeException |
translate(String sql,
List<Object> bindings,
SQLException ex)
Translate the given SQLException
|
public Configuration(SQLTemplates templates)
templates - templates for SQL serializationpublic String asLiteral(Object o)
o - objectpublic SQLTemplates getTemplates()
public Class<?> getJavaType(int sqlType, String typeName, int size, int digits, String tableName, String columnName)
sqlType - JDBC typetypeName - JDBC type namesize - sizedigits - digitstableName - table namecolumnName - column name@Nullable public <T> T get(ResultSet rs, @Nullable Path<?> path, int i, Class<T> clazz) throws SQLException
T - type to returnrs - result setpath - pathi - one based index in result set rowclazz - typeSQLException@Nullable public SchemaAndTable getOverride(SchemaAndTable key)
key - schema and tablepublic String getColumnOverride(SchemaAndTable key, String column)
key - schema and tablecolumn - columnpublic <T> void set(PreparedStatement stmt, Path<?> path, int i, T value) throws SQLException
T - stmt - statementpath - pathi - one based index in statementvalue - value to bindSQLExceptionpublic String getTypeName(Class<?> type)
type - java typepublic String getTypeNameForCast(Class<?> type)
type - java typepublic String registerSchemaOverride(String oldSchema, String newSchema)
oldSchema - schema to overridenewSchema - overridepublic String registerTableOverride(String oldTable, String newTable)
oldTable - table to overridenewTable - overridepublic String registerTableOverride(String schema, String oldTable, String newTable)
schema - schema of tableoldTable - table to overridenewTable - overridepublic SchemaAndTable registerTableOverride(String schema, String oldTable, String newSchema, String newTable)
schema - schema of tableoldTable - table to overridenewSchema - override schemanewTable - override tablepublic SchemaAndTable registerTableOverride(SchemaAndTable from, SchemaAndTable to)
from - schema and table to overrideto - overridepublic String registerColumnOverride(String schema, String table, String oldColumn, String newColumn)
schema - schematable - tableoldColumn - columnnewColumn - overridepublic String registerColumnOverride(String table, String oldColumn, String newColumn)
table - tableoldColumn - columnnewColumn - overridepublic void register(Type<?> type)
Type convertertype - typepublic void registerType(String typeName, Class<?> clazz)
typeName - SQL type nameclazz - java typepublic void registerNumeric(int total,
int decimal,
Class<?> javaType)
total - total amount of digitsdecimal - amount of fractional digitsjavaType - java typepublic void registerNumeric(int beginTotal,
int endTotal,
int beginDecimal,
int endDecimal,
Class<?> javaType)
beginTotal - inclusive start of rangeendTotal - inclusive end of rangebeginDecimal - inclusive start of rangeendDecimal - inclusive end of rangejavaType - java typepublic void register(String table, String column, Class<?> javaType)
table - tablecolumn - columnjavaType - java typepublic void register(String table, String column, Type<?> type)
Type converter for the given table and columntable - tablecolumn - columntype - typepublic RuntimeException translate(SQLException ex)
ex - SQLException to translatepublic RuntimeException translate(String sql, List<Object> bindings, 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)
useLiterals - true for literals and false for bindingspublic void setExceptionTranslator(SQLExceptionTranslator exceptionTranslator)
exceptionTranslator - exception translatorpublic void setTemplates(SQLTemplates templates)
templates - templatesCopyright © 2007–2015 Mysema Ltd. All rights reserved.