Class TransformedSqlColumn
java.lang.Object
com.randomnoun.common.jexl.sql.SqlColumn
com.randomnoun.common.jexl.sql.TransformedSqlColumn
An SQL column which represents a transformed value ( the value in the expression is not the stored value ).
Examples of TransformedSqlColumns:
- enum values ( 1-char in database exposed as enum strings )
- yes/no values ( 'Y'/'N' in database exposed as booleans )
- api-prefixed values ( 1234 in database exposed as "obj-1234" )
If the transformation is reversible, we can convert some expressions to use the raw column which can then leverage indexes on that column.
-
Field Summary
Fields inherited from class SqlColumn
ARRAY, BIGINT, BINARY, BIT, BLOB, BOOLEAN, CHAR, CLOB, DATALINK, dataType, DATE, DATEVALUE, DECIMAL, DISTINCT, DOUBLE, FIXEDDATEVALUE, FIXEDTIMEVALUE, FLOAT, INTEGER, JAVA_OBJECT, LONGVARBINARY, LONGVARCHAR, name, NULL, NUMERIC, OTHER, REAL, REF, SMALLINT, STRUCT, table, TIME, TIMESTAMP, TIMEVALUE, TINYINT, VARBINARY, VARCHAR -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract SqlColumnThe source columnabstract booleanIf true, we can perform null checks on the source column instead of the transformed valueabstract booleanIf true, we can reverse transformations for comparison operations; we can only do this if transformations preserve orderingabstract booleanIf true, we can reverse transformations for equals and not-equals comparisonsabstract ObjectreverseTransformLiteral(Object value) Reverse the transformation, i.e. convert a user-supplied value back into a database value.Methods inherited from class SqlColumn
getDataType, getFullName, getName, getTable, toString
-
Constructor Details
-
TransformedSqlColumn
-
-
Method Details
-
isNullPreserved
If true, we can perform null checks on the source column instead of the transformed value -
isReversableEquals
If true, we can reverse transformations for equals and not-equals comparisons -
isReversableComparison
If true, we can reverse transformations for comparison operations; we can only do this if transformations preserve ordering -
getSourceSqlColumn
The source column -
reverseTransformLiteral
public abstract Object reverseTransformLiteral(Object value) throws CannotReverseTransformationException Reverse the transformation, i.e. convert a user-supplied value back into a database value. The user-supplied value must be a literal (String, Boolean, Long etc), not an expression.- Parameters:
value- literal value in expression- Throws:
CannotReverseTransformationException
-