Class TypeMap
java.lang.Object
org.apache.torque.templates.typemapping.TypeMap
Various mappings for schema types, e.g. to their corresponding
Java object types, and Java native types.
These are the official SQL type to Java type mappings.
These don't quite correspond to the way the peer
system works so we'll have to make some adjustments.
------------------------------------------------------- SQL Type | Java Type | Peer Type ------------------------------------------------------- CHAR | String | String VARCHAR | String | String LONGVARCHAR | String | String NUMERIC | java.math.BigDecimal | java.math.BigDecimal DECIMAL | java.math.BigDecimal | java.math.BigDecimal BIT | boolean OR Boolean | Boolean TINYINT | byte OR Byte | Byte SMALLINT | short OR Short | Short INTEGER | int OR Integer | Integer BIGINT | long OR Long | Long REAL | float OR Float | Float FLOAT | double OR Double | Double DOUBLE | double OR Double | Double BINARY | byte[] | ? VARBINARY | byte[] | ? LONGVARBINARY | byte[] | ? DATE | java.sql.Date | java.util.Date TIME | java.sql.Time | java.util.Date TIMESTAMP | java.sql.Timestamp | java.util.Date ------------------------------------------------------- A couple variations have been introduced to cover cases that may arise, but are not covered above BOOLEANCHAR | boolean OR Boolean | String BOOLEANINT | boolean OR Boolean | Integer
- Version:
- $Id: TypeMap.java 1917023 2024-04-16 10:12:17Z gk $
- Author:
- Jason van Zyl, Martin Poeschl
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringA sample java object for BIGINT columns.static final StringA sample java object for BINARY columns.static final StringA sample java object for BIT columns.static final StringA sample java object for BLOB columns.static final StringA sample java object for BOOLEANCHAR columns.static final StringA sample java object for BOOLEANINT columns.static final StringA sample java object for CHAR columns.static final StringA sample java object for CLOB columns.static final StringA sample java object for DATE columns.static final StringA sample java object for DECIMAL columns.static final StringA sample java object for DOUBLE columns.static final StringA sample java object for FLOAT columns.static final StringA sample java object for INTEGER columns.static final StringA sample java object for LONGVARBINARY columns.static final StringA sample java object for LONGVARCHAR columns.static final StringA sample java object for NUMERIC columns.static final StringA sample java object for REAL columns.static final StringA sample java object for SMALLINT columns.static final StringA sample java object for TIME columns.static final StringA sample java object for TIMESTAMP columns.static final StringA sample java object for TINYINT columns.static final StringA sample java object for VARBINARY columns.static final StringA sample java object for VARCHAR columns. -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetJavaObject(SchemaType jdbcType) Return a Java object which corresponds to the JDBC type provided.static JavaTypegetJavaObjectType(SchemaType schemaType) Returns the java type which corresponds to the schema type provided.static JavaTypegetJavaPrimitiveType(SchemaType schemaType) Returns the java type which corresponds to the schema type provided.static ResultSetGettergetResultSetGetter(SchemaType schemaType) Returns the result set getter method which corresponds to the Schema type provided.static booleanisBit(SchemaType type) Returns true if the type is boolean in the java object and a Bit "1" or "0" in the db.static booleanisBooleanChar(SchemaType type) Returns true if the type is boolean in the java object and a String "Y" or "N" in the db.static booleanisBooleanInt(SchemaType type) Returns true if the type is boolean in the java object and a numeric (1 or 0) in the db.static booleanisTextType(SchemaType type) Returns true if values for the type need to be quoted.
-
Field Details
-
CHAR_OBJECT_TYPE
A sample java object for CHAR columns.- See Also:
-
VARCHAR_OBJECT_TYPE
A sample java object for VARCHAR columns.- See Also:
-
LONGVARCHAR_OBJECT_TYPE
A sample java object for LONGVARCHAR columns.- See Also:
-
CLOB_OBJECT_TYPE
A sample java object for CLOB columns.- See Also:
-
NUMERIC_OBJECT_TYPE
A sample java object for NUMERIC columns.- See Also:
-
DECIMAL_OBJECT_TYPE
A sample java object for DECIMAL columns.- See Also:
-
BIT_OBJECT_TYPE
A sample java object for BIT columns.- See Also:
-
TINYINT_OBJECT_TYPE
A sample java object for TINYINT columns.- See Also:
-
SMALLINT_OBJECT_TYPE
A sample java object for SMALLINT columns.- See Also:
-
INTEGER_OBJECT_TYPE
A sample java object for INTEGER columns.- See Also:
-
BIGINT_OBJECT_TYPE
A sample java object for BIGINT columns.- See Also:
-
REAL_OBJECT_TYPE
A sample java object for REAL columns.- See Also:
-
FLOAT_OBJECT_TYPE
A sample java object for FLOAT columns.- See Also:
-
DOUBLE_OBJECT_TYPE
A sample java object for DOUBLE columns.- See Also:
-
BINARY_OBJECT_TYPE
A sample java object for BINARY columns.- See Also:
-
VARBINARY_OBJECT_TYPE
A sample java object for VARBINARY columns.- See Also:
-
LONGVARBINARY_OBJECT_TYPE
A sample java object for LONGVARBINARY columns.- See Also:
-
BLOB_OBJECT_TYPE
A sample java object for BLOB columns.- See Also:
-
DATE_OBJECT_TYPE
A sample java object for DATE columns.- See Also:
-
TIME_OBJECT_TYPE
A sample java object for TIME columns.- See Also:
-
TIMESTAMP_OBJECT_TYPE
A sample java object for TIMESTAMP columns.- See Also:
-
BOOLEANCHAR_OBJECT_TYPE
A sample java object for BOOLEANCHAR columns.- See Also:
-
BOOLEANINT_OBJECT_TYPE
A sample java object for BOOLEANINT columns.- See Also:
-
-
Method Details
-
getJavaObject
Return a Java object which corresponds to the JDBC type provided. Use in MapBuilder generation.- Parameters:
jdbcType- the JDBC type- Returns:
- name of the Object
-
getJavaPrimitiveType
Returns the java type which corresponds to the schema type provided. Where possible, primitive types are used.- Parameters:
schemaType- the schema type.- Returns:
- name of the native java type
-
getJavaObjectType
Returns the java type which corresponds to the schema type provided. Only Object types are used.- Parameters:
schemaType- the schema type.- Returns:
- the corresponding java Type.
-
getResultSetGetter
Returns the result set getter method which corresponds to the Schema type provided.- Parameters:
schemaType- the schema type- Returns:
- the result set getter method.
-
isBooleanInt
Returns true if the type is boolean in the java object and a numeric (1 or 0) in the db.- Parameters:
type- The type to check.- Returns:
- true if the type is BOOLEANINT
-
isBooleanChar
Returns true if the type is boolean in the java object and a String "Y" or "N" in the db.- Parameters:
type- The type to check.- Returns:
- true if the type is BOOLEANCHAR
-
isBit
Returns true if the type is boolean in the java object and a Bit "1" or "0" in the db.- Parameters:
type- The type to check.- Returns:
- true if the type is BIT
-
isTextType
Returns true if values for the type need to be quoted.- Parameters:
type- The type to check.- Returns:
- true if values for the type need to be quoted.
-