public abstract class BaseDataType extends BaseFieldConverter implements DataPersister
Here's a good page about the mapping for a number of database types:
NOTE: If you are creating your own custom database persister, you probably will need to override the
BaseFieldConverter.sqlArgToJava(FieldType, Object, int) method as well which converts from a SQL data to
java.
| Constructor and Description |
|---|
BaseDataType(SqlType sqlType) |
BaseDataType(SqlType sqlType,
Class<?>[] classes) |
| Modifier and Type | Method and Description |
|---|---|
Object |
convertIdNumber(Number number)
Convert a
Number object to its primitive object suitable for assigning to a java ID field. |
boolean |
dataIsEqual(Object fieldObj1,
Object fieldObj2)
Compare two fields of this type returning true if equals else false.
|
Object |
generateId()
Return a generated id if appropriate or null if none.
|
Class<?>[] |
getAssociatedClasses()
Return the classes that should be associated with this.
|
String[] |
getAssociatedClassNames()
Return the class names that should be associated with this or null.
|
int |
getDefaultWidth()
Return the default width associated with this type or 0 if none.
|
Class<?> |
getPrimaryClass()
Return the class most associated with this persister or null if none.
|
String |
getSqlOtherType()
Get the type that should be used when defining this
|
SqlType |
getSqlType()
Return the SQL type that is stored in the database for this argument.
|
boolean |
isAppropriateId()
Return true if this data type can be an id column in a class.
|
boolean |
isArgumentHolderRequired()
Must use
ArgumentHolder when querying for values of this type. |
boolean |
isComparable()
Return true if this data type be compared in SQL statements.
|
boolean |
isEscapedDefaultValue()
Return whether this field's default value should be escaped in SQL.
|
boolean |
isEscapedValue()
Return whether we need to escape this value in SQL expressions.
|
boolean |
isPrimitive()
Return whether this field is a primitive type or not.
|
boolean |
isSelfGeneratedId()
Return true if this type creates its own generated ids else false to have the database do it.
|
boolean |
isValidForField(Field field)
Return true if the field is appropriate for this persister otherwise false.
|
boolean |
isValidForVersion()
Return true if this is a valid field for the
DatabaseField.version(). |
boolean |
isValidGeneratedType()
Return true if this type can be auto-generated by the database.
|
Object |
makeConfigObject(FieldType fieldType)
This makes a configuration object for the data-type or returns null if none.
|
Object |
moveToNextValue(Object currentValue)
Move the current-value to the next value.
|
Object |
resultStringToJava(FieldType fieldType,
String stringValue,
int columnPos)
Convert a string result value to the related Java field.
|
isStreamType, javaToSqlArg, resultToJava, sqlArgToJavaclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitisStreamType, javaToSqlArg, parseDefaultString, resultToJava, resultToSqlArg, sqlArgToJavapublic BaseDataType(SqlType sqlType, Class<?>[] classes)
sqlType - Type of the class as it is persisted in the databases.classes - Associated classes for this type. These should be specified if you want this type to be always used
for these Java classes. If this is a custom persister then this array should be empty.public BaseDataType(SqlType sqlType)
sqlType - Type of the class as it is persisted in the databases.public boolean isValidForField(Field field)
DataPersisterisValidForField in interface DataPersisterpublic Class<?> getPrimaryClass()
DataPersistergetPrimaryClass in interface DataPersisterpublic Object makeConfigObject(FieldType fieldType) throws SQLException
DataPersisterFieldType.getDataTypeConfigObj().makeConfigObject in interface DataPersisterSQLException - If there are problems creating the config object. Needed for subclasses.public SqlType getSqlType()
FieldConvertergetSqlType in interface FieldConverterpublic Class<?>[] getAssociatedClasses()
DataPersistergetAssociatedClasses in interface DataPersisterpublic String[] getAssociatedClassNames()
DataPersistergetAssociatedClassNames in interface DataPersisterpublic Object convertIdNumber(Number number)
DataPersisterNumber object to its primitive object suitable for assigning to a java ID field.convertIdNumber in interface DataPersisterpublic boolean isValidGeneratedType()
DataPersisterisValidGeneratedType in interface DataPersisterpublic boolean isEscapedDefaultValue()
DataPersisterisEscapedDefaultValue in interface DataPersisterpublic boolean isEscapedValue()
DataPersisterisEscapedValue in interface DataPersisterpublic boolean isPrimitive()
DataPersisterisPrimitive in interface DataPersisterpublic boolean isComparable()
DataPersisterisComparable in interface DataPersisterpublic boolean isAppropriateId()
DataPersisterisAppropriateId in interface DataPersisterpublic boolean isArgumentHolderRequired()
DataPersisterArgumentHolder when querying for values of this type.isArgumentHolderRequired in interface DataPersisterpublic boolean isSelfGeneratedId()
DataPersisterisSelfGeneratedId in interface DataPersisterpublic Object generateId()
DataPersistergenerateId in interface DataPersisterpublic int getDefaultWidth()
DataPersistergetDefaultWidth in interface DataPersisterpublic boolean dataIsEqual(Object fieldObj1, Object fieldObj2)
DataPersisterdataIsEqual in interface DataPersisterpublic boolean isValidForVersion()
DataPersisterDatabaseField.version().isValidForVersion in interface DataPersisterpublic Object moveToNextValue(Object currentValue) throws SQLException
moveToNextValue in interface DataPersisterSQLException - For sub-classes.public Object resultStringToJava(FieldType fieldType, String stringValue, int columnPos) throws SQLException
FieldConverterresultStringToJava in interface FieldConverterSQLExceptionpublic String getSqlOtherType()
DataPersistergetSqlOtherType in interface DataPersisterThis documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.