Package io.ebeaninternal.server.type
Class ScalarTypeEnumWithMapping
- java.lang.Object
-
- io.ebeaninternal.server.type.ScalarTypeBase
-
- io.ebeaninternal.server.type.ScalarTypeEnumStandard.EnumBase
-
- io.ebeaninternal.server.type.ScalarTypeEnumWithMapping
-
- All Implemented Interfaces:
StringFormatter
,StringParser
,ScalarDataReader
,ScalarType
,ScalarTypeEnum
- Direct Known Subclasses:
ScalarTypeDayOfWeek
,ScalarTypeMonth
public class ScalarTypeEnumWithMapping extends ScalarTypeEnumStandard.EnumBase implements ScalarType, ScalarTypeEnum
Additional control over mapping to DB values.
-
-
Constructor Summary
Constructors Constructor Description ScalarTypeEnumWithMapping(EnumToDbValueMap<?> beanDbMap, Class<?> enumType, int length)
Create with an explicit mapping of bean to database values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
asVersion(Object value)
Convert the value into a long version value.void
bind(DataBind b, Object value)
Convert (if necessary) and bind the value to the preparedStatement.Set<String>
getDbCheckConstraintValues()
Return the IN values for DB constraint construction.int
getLength()
Return the DB column length for storing the enum value.boolean
isBinaryType()
Return true if this is a binary type and can not support parse() and format() from/to string.boolean
isCompatible(javax.persistence.EnumType enumType)
Return true if the scalar type is compatible with the specified enum type.Object
read(DataReader dataReader)
Read the value from the resultSet and convert if necessary to the logical bean property value.Object
toBeanType(Object dbValue)
Convert the value as necessary to the logical Bean type.Object
toJdbcType(Object beanValue)
Convert the value as necessary to the JDBC type.-
Methods inherited from class io.ebeaninternal.server.type.ScalarTypeEnumStandard.EnumBase
convertFromMillis, format, formatValue, getDocType, isDateTimeCapable, jsonRead, jsonWrite, parse, readData, writeData
-
Methods inherited from class io.ebeaninternal.server.type.ScalarTypeBase
getJdbcType, getType, isDirty, isJdbcNative, isMutable, loadIgnore
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.ebeaninternal.server.type.ScalarType
convertFromMillis, format, formatValue, getDocType, getJdbcType, getType, isDateTimeCapable, isDirty, isJdbcNative, isMutable, jsonRead, jsonWrite, loadIgnore, parse, readData, writeData
-
Methods inherited from interface io.ebeaninternal.server.type.ScalarTypeEnum
isOverrideBy
-
-
-
-
Constructor Detail
-
ScalarTypeEnumWithMapping
public ScalarTypeEnumWithMapping(EnumToDbValueMap<?> beanDbMap, Class<?> enumType, int length)
Create with an explicit mapping of bean to database values.
-
-
Method Detail
-
isCompatible
public boolean isCompatible(javax.persistence.EnumType enumType)
Description copied from interface:ScalarTypeEnum
Return true if the scalar type is compatible with the specified enum type.- Specified by:
isCompatible
in interfaceScalarTypeEnum
-
asVersion
public long asVersion(Object value)
Description copied from interface:ScalarType
Convert the value into a long version value.- Specified by:
asVersion
in interfaceScalarType
- Overrides:
asVersion
in classScalarTypeBase
-
isBinaryType
public boolean isBinaryType()
Description copied from interface:ScalarType
Return true if this is a binary type and can not support parse() and format() from/to string. This allows Ebean to optimise marshalling types to string.- Specified by:
isBinaryType
in interfaceScalarType
- Overrides:
isBinaryType
in classScalarTypeBase
-
getDbCheckConstraintValues
public Set<String> getDbCheckConstraintValues()
Return the IN values for DB constraint construction.- Specified by:
getDbCheckConstraintValues
in interfaceScalarTypeEnum
-
getLength
public int getLength()
Return the DB column length for storing the enum value.This is for enum's mapped to strings.
- Specified by:
getLength
in interfaceScalarType
- Overrides:
getLength
in classScalarTypeBase
-
bind
public void bind(DataBind b, Object value) throws SQLException
Description copied from interface:ScalarType
Convert (if necessary) and bind the value to the preparedStatement.value may need to be converted from the logical bean property type to the JDBC type.
- Specified by:
bind
in interfaceScalarType
- Throws:
SQLException
-
read
public Object read(DataReader dataReader) throws SQLException
Description copied from interface:ScalarType
Read the value from the resultSet and convert if necessary to the logical bean property value.- Specified by:
read
in interfaceScalarDataReader
- Specified by:
read
in interfaceScalarType
- Throws:
SQLException
-
toBeanType
public Object toBeanType(Object dbValue)
Description copied from interface:ScalarType
Convert the value as necessary to the logical Bean type.The type as per the bean property.
This is used to automatically convert id values (typically from a string to a int, long or UUID).
- Specified by:
toBeanType
in interfaceScalarType
-
toJdbcType
public Object toJdbcType(Object beanValue)
Description copied from interface:ScalarType
Convert the value as necessary to the JDBC type.Note that this should also match the type as per the getJdbcType() method.
This is typically used when the matching type is used in a where clause and we use this to ensure it is an appropriate jdbc type.
- Specified by:
toJdbcType
in interfaceScalarType
-
-