Interface IdBinder
-
- All Known Implementing Classes:
IdBinderEmbedded
,IdBinderEmpty
,IdBinderSimple
public interface IdBinder
Binds id values to prepared statements.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addIdInBindValues(SpiExpressionRequest request, Collection<?> ids)
Binds multiple id value to a request.void
addIdInBindValues(DefaultSqlUpdate sqlUpdate, Collection<?> ids)
Binds multiple id value to an update.void
appendSelect(DbSqlContext ctx, boolean subQuery)
Append to the select clause.void
bindId(DefaultSqlUpdate sqlUpdate, Object value)
Bind the id value to a SqlUpdate statement.void
bindId(DataBind dataBind, Object value)
Binds an id value to a prepared statement.void
buildRawSqlSelectChain(String prefix, List<String> selectChain)
String
cacheKey(Object idValue)
Return a key to use for bean caches given the id value.String
cacheKeyFromBean(EntityBean bean)
Return a key to use for bean caches given the bean.Object
convertId(Object idValue)
Cast or convert the Id value if necessary.Object
convertIdFromJson(Object value)
For EmbeddedId the value is assumed to be a Map and this is takes the values from the map and builds an embedded id bean.Object
convertSetId(Object idValue, EntityBean bean)
Cast or convert the Id value if necessary and optionally set it.BeanProperty
findBeanProperty(String dbColumnName)
Find a BeanProperty that is mapped to the database column.String
getAssocIdInExpr(String prefix)
Return the logical id in expression taking into account embedded id's.String
getAssocOneIdExpr(String prefix, String operator)
Build a string of the logical expressions.STreeProperty
getBeanProperty()
Return the Id BeanProperty.String
getBindIdInSql(String baseTableAlias)
Return the sql for binding the id using an IN clause.String
getBindIdSql(String baseTableAlias)
Return the sql for binding the id to.Object[]
getBindValues(Object idValue)
Return the values as an array of scalar bindable values.String
getDefaultOrderBy()
Return the default order by that may need to be used if the query includes a many property.Object
getIdForJson(EntityBean idValue)
For EmbeddedId convert the idValue into a simple map.String
getIdInValueExpr(boolean not, int size)
Return the binding expression (like "?" or "(?,?)")for the Id.String
getIdInValueExprDelete(int size)
Same as getIdInValueExpr but for delete by id.String
getIdProperty()
Return the name(s) of the Id property(s).Object[]
getIdValues(EntityBean bean)
Return the id values for a given bean.String
getOrderBy(String pathPrefix, boolean ascending)
void
initialise()
Initialise the binder.boolean
isComplexId()
Return false if the id is a simple scalar and false if it is embedded or concatenated.boolean
isIdInExpandedForm()
Return true if this is a compound key and must use expanded and or form.void
loadIgnore(DbReadContext ctx)
Ignore the appropriate number of scalar properties for this id.Object
read(DbReadContext ctx)
Read the id value from the result set and return it.Object
readData(DataInput dataInput)
Read the Id value from the binary DataInput.Object
readSet(DbReadContext ctx, EntityBean bean)
Read the id value from the result set and set it to the bean also returning it.void
writeData(DataOutput dataOutput, Object idValue)
Write the Id value to binary DataOuput.
-
-
-
Method Detail
-
initialise
void initialise()
Initialise the binder.
-
isIdInExpandedForm
boolean isIdInExpandedForm()
Return true if this is a compound key and must use expanded and or form.
-
writeData
void writeData(DataOutput dataOutput, Object idValue) throws IOException
Write the Id value to binary DataOuput.- Throws:
IOException
-
readData
Object readData(DataInput dataInput) throws IOException
Read the Id value from the binary DataInput.- Throws:
IOException
-
getIdProperty
String getIdProperty()
Return the name(s) of the Id property(s). Comma delimited if there is more than one.This can be used to include in a query.
-
getBeanProperty
STreeProperty getBeanProperty()
Return the Id BeanProperty.
-
findBeanProperty
BeanProperty findBeanProperty(String dbColumnName)
Find a BeanProperty that is mapped to the database column.
-
isComplexId
boolean isComplexId()
Return false if the id is a simple scalar and false if it is embedded or concatenated.
-
getDefaultOrderBy
String getDefaultOrderBy()
Return the default order by that may need to be used if the query includes a many property.
-
getOrderBy
String getOrderBy(String pathPrefix, boolean ascending)
-
getBindValues
Object[] getBindValues(Object idValue)
Return the values as an array of scalar bindable values.For concatenated keys that use an Embedded bean or multiple id properties this determines the field values are returns them as an Object array.
Added primarily for Query.addWhere().add(Expr.idEq()) support.
-
getIdForJson
Object getIdForJson(EntityBean idValue)
For EmbeddedId convert the idValue into a simple map. Otherwise the idValue is just returned as is.This is used to provide a simple JSON serializable version of the id value.
-
convertIdFromJson
Object convertIdFromJson(Object value)
For EmbeddedId the value is assumed to be a Map and this is takes the values from the map and builds an embedded id bean.For other simple id's this just returns the value (no conversion required).
This is used to provide a simple JSON serializable version of the id value.
-
getIdValues
Object[] getIdValues(EntityBean bean)
Return the id values for a given bean.
-
getAssocOneIdExpr
String getAssocOneIdExpr(String prefix, String operator)
Build a string of the logical expressions.Typically used to build a id = ? string.
-
getAssocIdInExpr
String getAssocIdInExpr(String prefix)
Return the logical id in expression taking into account embedded id's.
-
bindId
void bindId(DataBind dataBind, Object value) throws SQLException
Binds an id value to a prepared statement.- Throws:
SQLException
-
bindId
void bindId(DefaultSqlUpdate sqlUpdate, Object value)
Bind the id value to a SqlUpdate statement.
-
addIdInBindValues
void addIdInBindValues(DefaultSqlUpdate sqlUpdate, Collection<?> ids)
Binds multiple id value to an update.
-
addIdInBindValues
void addIdInBindValues(SpiExpressionRequest request, Collection<?> ids)
Binds multiple id value to a request.
-
getBindIdInSql
String getBindIdInSql(String baseTableAlias)
Return the sql for binding the id using an IN clause.
-
getIdInValueExpr
String getIdInValueExpr(boolean not, int size)
Return the binding expression (like "?" or "(?,?)")for the Id.
-
getIdInValueExprDelete
String getIdInValueExprDelete(int size)
Same as getIdInValueExpr but for delete by id.
-
buildRawSqlSelectChain
void buildRawSqlSelectChain(String prefix, List<String> selectChain)
-
readSet
Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException
Read the id value from the result set and set it to the bean also returning it.- Throws:
SQLException
-
loadIgnore
void loadIgnore(DbReadContext ctx)
Ignore the appropriate number of scalar properties for this id.
-
read
Object read(DbReadContext ctx) throws SQLException
Read the id value from the result set and return it.- Throws:
SQLException
-
appendSelect
void appendSelect(DbSqlContext ctx, boolean subQuery)
Append to the select clause.
-
getBindIdSql
String getBindIdSql(String baseTableAlias)
Return the sql for binding the id to. This includes table alias and columns that make up the id.
-
convertSetId
Object convertSetId(Object idValue, EntityBean bean)
Cast or convert the Id value if necessary and optionally set it.The Id value is not assumed to be the correct type so it is converted to the correct type. Typically this is because we could get a Integer, Long or BigDecimal depending on the JDBC driver and situation.
If the bean is not null, then the value is set to the bean.
-
cacheKeyFromBean
String cacheKeyFromBean(EntityBean bean)
Return a key to use for bean caches given the bean.
-
-