Class UUIDType
java.lang.Object
org.apache.cayenne.access.types.UUIDType
- All Implemented Interfaces:
ExtendedType<UUID>
An ExtendedType for
java.util.UUID that picks the storage format from the JDBC type of the mapped
column:
- character columns store the canonical 36-char string;
- binary columns store the 16-byte big-endian form, most significant bits first;
- anything else is passed to the driver as an object, which is how a PostgreSQL native
uuidcolumn works.
- Since:
- 5.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe length of the binary form of a UUID.Fields inherited from interface ExtendedType
TRIM_VALUES_THRESHOLD -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic UUIDfromBytes(byte[] value) Converts a 16-byte big-endian value, most significant bits first, to a UUID.protected static UUIDfromObject(Object value) Converts whatever the driver returned for a column of an unrecognized JDBC type.protected static UUIDfromString(String value) Returns a full name of Java class that this ExtendedType supports.materializeObject(CallableStatement rs, int index, int type) Reads an object from a stored procedure OUT parameter, converting it to class returned by 'getClassName' method.materializeObject(ResultSet rs, int index, int type) Reads an object from JDBC ResultSet column, converting it to class returned by 'getClassName' method.voidsetJdbcObject(PreparedStatement statement, UUID value, int pos, int type, int scale) Initializes a single parameter of a PreparedStatement with object value.static byte[]Converts a UUID to its 16-byte big-endian form, most significant bits first.Converts value of the supported type to a human-readable String representation.
-
Field Details
-
UUID_BYTES
public static final int UUID_BYTESThe length of the binary form of a UUID.- See Also:
-
-
Constructor Details
-
UUIDType
public UUIDType()
-
-
Method Details
-
getClassName
Description copied from interface:ExtendedTypeReturns a full name of Java class that this ExtendedType supports.- Specified by:
getClassNamein interfaceExtendedType<UUID>
-
materializeObject
Description copied from interface:ExtendedTypeReads an object from JDBC ResultSet column, converting it to class returned by 'getClassName' method.- Specified by:
materializeObjectin interfaceExtendedType<UUID>- Throws:
Exception- if read error occurred, or an object can't be converted to a target Java class.
-
materializeObject
Description copied from interface:ExtendedTypeReads an object from a stored procedure OUT parameter, converting it to class returned by 'getClassName' method.- Specified by:
materializeObjectin interfaceExtendedType<UUID>- Throws:
Exception- if read error occurred, or an object can't be converted to a target Java class.
-
setJdbcObject
public void setJdbcObject(PreparedStatement statement, UUID value, int pos, int type, int scale) throws Exception Description copied from interface:ExtendedTypeInitializes a single parameter of a PreparedStatement with object value.- Specified by:
setJdbcObjectin interfaceExtendedType<UUID>- Throws:
Exception
-
toString
Description copied from interface:ExtendedTypeConverts value of the supported type to a human-readable String representation.- Specified by:
toStringin interfaceExtendedType<UUID>- Parameters:
value- a value to convert to String.
-
toBytes
Converts a UUID to its 16-byte big-endian form, most significant bits first. -
fromBytes
Converts a 16-byte big-endian value, most significant bits first, to a UUID. -
fromString
-
fromObject
-