Package net.java.ao.types
Interface LogicalType<T>
public interface LogicalType<T>
Defines a logical type which can translate between one or more Java types and one or more JDBC types.
This should be independent of the underlying database dialect.
-
Method Summary
Modifier and TypeMethodDescriptionReturns the set of JDBC types that can be translated into this logical type.Returns the Java types that are handled by this logical type.intReturns the default JDBC type to use when writing values to the database.getName()Returns a descriptive name for this logical type.booleanReturns a boolean specifying if this type can be used as a primary key value.Attempts to parse a string into a value of this logical type.parseDefault(String input) Same asparse(String), but adds any necessary validation when the value is being used as a default value for a column.pullFromDatabase(EntityManager manager, ResultSet res, Class<T> type, int columnIndex) Reads a value from a JDBC result set.pullFromDatabase(EntityManager manager, ResultSet res, Class<T> type, String columnName) Reads a value from a JDBC result set.voidputToDatabase(EntityManager manager, PreparedStatement stmt, int index, T value, int jdbcType) Sets a value in a JDBC statement.booleanshouldCache(Class<?> type) Deprecated.since 0.25.booleanshouldStore(Class<?> type) Returns whether the type may be put inside the entities value store.Verifies that a value can be stored in the database.booleanvalueEquals(Object val1, Object val2) valueToString(T value)
-
Method Details
-
getName
String getName()Returns a descriptive name for this logical type. -
getAllTypes
Returns the Java types that are handled by this logical type. Only one logical type can handle any given Java type. -
getAllJdbcReadTypes
Returns the set of JDBC types that can be translated into this logical type. -
getDefaultJdbcWriteType
int getDefaultJdbcWriteType()Returns the default JDBC type to use when writing values to the database. This can be overridden by each database provider in theSchemaProperties. -
isAllowedAsPrimaryKey
boolean isAllowedAsPrimaryKey()Returns a boolean specifying if this type can be used as a primary key value.- Returns:
- if it's allowed or not
-
parse
Attempts to parse a string into a value of this logical type.- Throws:
IllegalArgumentException
-
parseDefault
Same asparse(String), but adds any necessary validation when the value is being used as a default value for a column.- Throws:
IllegalArgumentException
-
validate
Verifies that a value can be stored in the database. Returns the same value or a canonically equivalent value.- Throws:
IllegalArgumentException
-
putToDatabase
void putToDatabase(EntityManager manager, PreparedStatement stmt, int index, T value, int jdbcType) throws SQLException Sets a value in a JDBC statement.- Throws:
SQLException
-
pullFromDatabase
T pullFromDatabase(EntityManager manager, ResultSet res, Class<T> type, String columnName) throws SQLException Reads a value from a JDBC result set.- Throws:
SQLException
-
pullFromDatabase
T pullFromDatabase(EntityManager manager, ResultSet res, Class<T> type, int columnIndex) throws SQLException Reads a value from a JDBC result set.- Throws:
SQLException
-
shouldCache
Deprecated.since 0.25. Entities and values now no longer cached. -
shouldStore
Returns whether the type may be put inside the entities value store. -
valueEquals
-
valueToString
-