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 |
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, makeConfigObject, resultToJava, sqlArgToJava
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
isStreamType, javaToSqlArg, makeConfigObject, parseDefaultString, resultToJava, resultToSqlArg, sqlArgToJava
public 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)
DataPersister
isValidForField
in interface DataPersister
public Class<?> getPrimaryClass()
DataPersister
getPrimaryClass
in interface DataPersister
public SqlType getSqlType()
FieldConverter
getSqlType
in interface FieldConverter
public Class<?>[] getAssociatedClasses()
DataPersister
getAssociatedClasses
in interface DataPersister
public String[] getAssociatedClassNames()
DataPersister
getAssociatedClassNames
in interface DataPersister
public Object convertIdNumber(Number number)
DataPersister
Number
object to its primitive object suitable for assigning to a java ID field.convertIdNumber
in interface DataPersister
public boolean isValidGeneratedType()
DataPersister
isValidGeneratedType
in interface DataPersister
public boolean isEscapedDefaultValue()
DataPersister
isEscapedDefaultValue
in interface DataPersister
public boolean isEscapedValue()
DataPersister
isEscapedValue
in interface DataPersister
public boolean isPrimitive()
DataPersister
isPrimitive
in interface DataPersister
public boolean isComparable()
DataPersister
isComparable
in interface DataPersister
public boolean isAppropriateId()
DataPersister
isAppropriateId
in interface DataPersister
public boolean isArgumentHolderRequired()
DataPersister
ArgumentHolder
when querying for values of this type.isArgumentHolderRequired
in interface DataPersister
public boolean isSelfGeneratedId()
DataPersister
isSelfGeneratedId
in interface DataPersister
public Object generateId()
DataPersister
generateId
in interface DataPersister
public int getDefaultWidth()
DataPersister
getDefaultWidth
in interface DataPersister
public boolean dataIsEqual(Object fieldObj1, Object fieldObj2)
DataPersister
dataIsEqual
in interface DataPersister
public boolean isValidForVersion()
DataPersister
DatabaseField.version()
.isValidForVersion
in interface DataPersister
public Object moveToNextValue(Object currentValue) throws SQLException
moveToNextValue
in interface DataPersister
SQLException
- For sub-classes.public Object resultStringToJava(FieldType fieldType, String stringValue, int columnPos) throws SQLException
FieldConverter
resultStringToJava
in interface FieldConverter
SQLException
public String getSqlOtherType()
DataPersister
getSqlOtherType
in interface DataPersister
This documentation is licensed by Gray Watson under the Creative Commons Attribution-Share Alike 3.0 License.