Package org.apache.cayenne.dba
Class TypesMapping
java.lang.Object
org.apache.cayenne.dba.TypesMapping
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 SummaryFieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic String[]Returns an array of string names of the default JDBC data types.static StringgetJavaBySqlType(int type) Get the corresponding Java type by itsTypescounterpart.static StringgetJavaBySqlType(DbAttribute attribute) 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 booleanisDateTime(int 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.
- 
Field Details- 
NOT_DEFINEDpublic static final int NOT_DEFINED- See Also:
 
- 
SQL_ARRAY- See Also:
 
- 
SQL_BIGINT- See Also:
 
- 
SQL_BINARY- See Also:
 
- 
SQL_BIT- See Also:
 
- 
SQL_BLOB- See Also:
 
- 
SQL_BOOLEAN- Since:
- 1.2
- See Also:
 
- 
SQL_CLOB- See Also:
 
- 
SQL_NCLOB- See Also:
 
- 
SQL_CHAR- See Also:
 
- 
SQL_NCHAR- See Also:
 
- 
SQL_DATE- See Also:
 
- 
SQL_DECIMAL- See Also:
 
- 
SQL_DOUBLE- See Also:
 
- 
SQL_FLOAT- See Also:
 
- 
SQL_INTEGER- See Also:
 
- 
SQL_LONGVARCHAR- See Also:
 
- 
SQL_LONGNVARCHAR- See Also:
 
- 
SQL_LONGVARBINARY- See Also:
 
- 
SQL_NUMERIC- See Also:
 
- 
SQL_REAL- See Also:
 
- 
SQL_SMALLINT- See Also:
 
- 
SQL_TINYINT- See Also:
 
- 
SQL_TIME- See Also:
 
- 
SQL_TIMESTAMP- See Also:
 
- 
SQL_VARBINARY- See Also:
 
- 
SQL_VARCHAR- See Also:
 
- 
SQL_NVARCHAR- See Also:
 
- 
SQL_SQLXML- See Also:
 
- 
SQL_OTHER- See Also:
 
- 
SQL_NULL- See Also:
 
- 
JAVA_LONG- See Also:
 
- 
JAVA_BYTES- See Also:
 
- 
JAVA_BOOLEAN- See Also:
 
- 
JAVA_STRING- See Also:
 
- 
JAVA_SQLDATE- See Also:
 
- 
JAVA_UTILDATE- See Also:
 
- 
JAVA_BIGDECIMAL- See Also:
 
- 
JAVA_BIGINTEGER- See Also:
 
- 
JAVA_DOUBLE- See Also:
 
- 
JAVA_FLOAT- See Also:
 
- 
JAVA_INTEGER- See Also:
 
- 
JAVA_SHORT- See Also:
 
- 
JAVA_BYTE- See Also:
 
- 
JAVA_TIME- See Also:
 
- 
JAVA_TIMESTAMP- See Also:
 
- 
JAVA_BLOB- See Also:
 
 
- 
- 
Constructor Details- 
TypesMapping- Throws:
- SQLException
 
 
- 
- 
Method Details- 
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.
- 
isDateTimepublic static boolean isDateTime(int type) - Since:
- 5.0
 
- 
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 itsTypescounterpart. 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.- Parameters:
- type- as defined in- Types
- Returns:
- Fully qualified Java type name or null if not found.
 
- 
getJavaBySqlType- Parameters:
- attribute- to get java type for
- Returns:
- Fully qualified Java type name or null if not found.
- Since:
- 4.2
- See Also:
 
 
-