Package org.apache.cayenne.dba
Class TypesMapping
java.lang.Object
org.apache.cayenne.dba.TypesMapping
public class TypesMapping extends Object
A utility class that handles mappings of JDBC data types to the database
 types and Java types. Also contains methods that provide information about
 JDBC types.
- 
Field Summary
- 
Constructor SummaryConstructors Constructor Description TypesMapping(DatabaseMetaData metaData)
- 
Method SummaryModifier and Type Method Description static String[]getDatabaseTypes()Returns an array of string names of the default JDBC data types.static StringgetJavaBySqlType(int type)Get the corresponding Java type by its java.sql.Types counterpart.static StringgetSqlNameByType(int type)Returns a String representation of the SQL type from its JDBC code.static intgetSqlTypeByJava(Class<?> javaClass)Guesses a default JDBC type for the Java class.static intgetSqlTypeByJava(String className)Returns default java.sql.Types type by the Java type name.static intgetSqlTypeByName(String typeName)Returns a JDBC int type for SQL typem name.static booleanisBinary(int type)Returns true if supplied type is a binary type.static booleanisCharacter(int type)Returns true if supplied type is a character type.static booleanisDecimal(int type)Returns true if supplied type is a decimal type.static booleanisNumeric(int type)Returns true if supplied type is a numeric type.protected static StringpickDataType(int jdbcType, org.apache.cayenne.dba.TypesMapping.TypeInfo[] alts)Method implements an algorithm to pick a data type from a list of alternatives that most closely matches JDBC data type.static booleansupportsLength(int type)Deprecated.Returns true if supplied type can have a length attribute as a part of column definition.
- 
Field Details- 
NOT_DEFINEDpublic static final int NOT_DEFINED- See Also:
- Constant Field Values
 
- 
SQL_ARRAY- See Also:
- Constant Field Values
 
- 
SQL_BIGINT- See Also:
- Constant Field Values
 
- 
SQL_BINARY- See Also:
- Constant Field Values
 
- 
SQL_BIT- See Also:
- Constant Field Values
 
- 
SQL_BLOB- See Also:
- Constant Field Values
 
- 
SQL_BOOLEAN- Since:
- 1.2
- See Also:
- Constant Field Values
 
- 
SQL_CLOB- See Also:
- Constant Field Values
 
- 
SQL_NCLOB- See Also:
- Constant Field Values
 
- 
SQL_CHAR- See Also:
- Constant Field Values
 
- 
SQL_NCHAR- See Also:
- Constant Field Values
 
- 
SQL_DATE- See Also:
- Constant Field Values
 
- 
SQL_DECIMAL- See Also:
- Constant Field Values
 
- 
SQL_DOUBLE- See Also:
- Constant Field Values
 
- 
SQL_FLOAT- See Also:
- Constant Field Values
 
- 
SQL_INTEGER- See Also:
- Constant Field Values
 
- 
SQL_LONGVARCHAR- See Also:
- Constant Field Values
 
- 
SQL_LONGNVARCHAR- See Also:
- Constant Field Values
 
- 
SQL_LONGVARBINARY- See Also:
- Constant Field Values
 
- 
SQL_NUMERIC- See Also:
- Constant Field Values
 
- 
SQL_REAL- See Also:
- Constant Field Values
 
- 
SQL_SMALLINT- See Also:
- Constant Field Values
 
- 
SQL_TINYINT- See Also:
- Constant Field Values
 
- 
SQL_TIME- See Also:
- Constant Field Values
 
- 
SQL_TIMESTAMP- See Also:
- Constant Field Values
 
- 
SQL_VARBINARY- See Also:
- Constant Field Values
 
- 
SQL_VARCHAR- See Also:
- Constant Field Values
 
- 
SQL_NVARCHAR- See Also:
- Constant Field Values
 
- 
SQL_SQLXML- See Also:
- Constant Field Values
 
- 
SQL_OTHER- See Also:
- Constant Field Values
 
- 
SQL_NULL- See Also:
- Constant Field Values
 
- 
JAVA_LONG- See Also:
- Constant Field Values
 
- 
JAVA_BYTES- See Also:
- Constant Field Values
 
- 
JAVA_BOOLEAN- See Also:
- Constant Field Values
 
- 
JAVA_STRING- See Also:
- Constant Field Values
 
- 
JAVA_SQLDATE- See Also:
- Constant Field Values
 
- 
JAVA_UTILDATE- See Also:
- Constant Field Values
 
- 
JAVA_BIGDECIMAL- See Also:
- Constant Field Values
 
- 
JAVA_DOUBLE- See Also:
- Constant Field Values
 
- 
JAVA_FLOAT- See Also:
- Constant Field Values
 
- 
JAVA_INTEGER- See Also:
- Constant Field Values
 
- 
JAVA_SHORT- See Also:
- Constant Field Values
 
- 
JAVA_BYTE- See Also:
- Constant Field Values
 
- 
JAVA_TIME- See Also:
- Constant Field Values
 
- 
JAVA_TIMESTAMP- See Also:
- Constant Field Values
 
- 
JAVA_BLOB- See Also:
- Constant Field Values
 
 
- 
- 
Constructor Details- 
TypesMapping- Throws:
- SQLException
 
 
- 
- 
Method Details- 
supportsLengthpublic static boolean supportsLength(int type)Deprecated.Returns true if supplied type can have a length attribute as a part of column definition.
- 
isCharacterpublic static boolean isCharacter(int type)Returns true if supplied type is a character type.- Parameters:
- type- JDBC type
- Returns:
- true if supplied type is a character type.
- Since:
- 4.0
 
- 
isBinarypublic static boolean isBinary(int type)Returns true if supplied type is a binary type.- Parameters:
- type- JDBC type
- Returns:
- true if supplied type is a binary type.
- Since:
- 4.0
 
- 
isNumericpublic static boolean isNumeric(int type)Returns true if supplied type is a numeric type.
- 
isDecimalpublic static boolean isDecimal(int type)Returns true if supplied type is a decimal type.
- 
getDatabaseTypesReturns an array of string names of the default JDBC data types.
- 
pickDataTypeprotected static String pickDataType(int jdbcType, org.apache.cayenne.dba.TypesMapping.TypeInfo[] alts)Method implements an algorithm to pick a data type from a list of alternatives that most closely matches JDBC data type.
- 
getSqlTypeByNameReturns a JDBC int type for SQL typem name.
- 
getSqlNameByTypeReturns a String representation of the SQL type from its JDBC code.
- 
getSqlTypeByJavaReturns default java.sql.Types type by the Java type name.- Parameters:
- className- Fully qualified Java Class name.
- Returns:
- The SQL type or NOT_DEFINED if no type found.
 
- 
getSqlTypeByJavaGuesses a default JDBC type for the Java class.- Since:
- 1.1
 
- 
getJavaBySqlTypeGet the corresponding Java type by its java.sql.Types counterpart. Note that this method should be used as a last resort, with explicit mapping provided by user used as a first choice, as it can only guess how to map certain types, such as NUMERIC, etc.- Returns:
- Fully qualified Java type name or null if not found.
 
 
-