Class IdBinderEmbedded
- java.lang.Object
-
- io.ebeaninternal.server.deploy.id.IdBinderEmbedded
-
- All Implemented Interfaces:
IdBinder
public final class IdBinderEmbedded extends Object implements IdBinder
Bind an Id that is an Embedded bean.
-
-
Constructor Summary
Constructors Constructor Description IdBinderEmbedded(boolean idInExpandedForm, BeanPropertyAssocOne<?> embIdProperty)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addIdInBindValues(SpiExpressionRequest request, Collection<?> values)
Binds multiple id value to a request.void
addIdInBindValues(DefaultSqlUpdate sqlUpdate, Collection<?> values)
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 value)
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)
Convert back from a Map to embedded 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.BeanProperty
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 value)
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.BeanDescriptor<?>
getIdBeanDescriptor()
Object
getIdForJson(EntityBean bean)
Convert from embedded bean to 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)
BeanProperty[]
getProperties()
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.
-
-
-
Constructor Detail
-
IdBinderEmbedded
public IdBinderEmbedded(boolean idInExpandedForm, BeanPropertyAssocOne<?> embIdProperty)
-
-
Method Detail
-
initialise
public void initialise()
Description copied from interface:IdBinder
Initialise the binder.- Specified by:
initialise
in interfaceIdBinder
-
isIdInExpandedForm
public boolean isIdInExpandedForm()
Description copied from interface:IdBinder
Return true if this is a compound key and must use expanded and or form.- Specified by:
isIdInExpandedForm
in interfaceIdBinder
-
getBeanProperty
public BeanProperty getBeanProperty()
Description copied from interface:IdBinder
Return the Id BeanProperty.- Specified by:
getBeanProperty
in interfaceIdBinder
-
getOrderBy
public String getOrderBy(String pathPrefix, boolean ascending)
- Specified by:
getOrderBy
in interfaceIdBinder
-
getIdBeanDescriptor
public BeanDescriptor<?> getIdBeanDescriptor()
-
getIdProperty
public String getIdProperty()
Description copied from interface:IdBinder
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.
- Specified by:
getIdProperty
in interfaceIdBinder
-
buildRawSqlSelectChain
public void buildRawSqlSelectChain(String prefix, List<String> selectChain)
- Specified by:
buildRawSqlSelectChain
in interfaceIdBinder
-
findBeanProperty
public BeanProperty findBeanProperty(String dbColumnName)
Description copied from interface:IdBinder
Find a BeanProperty that is mapped to the database column.- Specified by:
findBeanProperty
in interfaceIdBinder
-
isComplexId
public boolean isComplexId()
Description copied from interface:IdBinder
Return false if the id is a simple scalar and false if it is embedded or concatenated.- Specified by:
isComplexId
in interfaceIdBinder
-
getDefaultOrderBy
public String getDefaultOrderBy()
Description copied from interface:IdBinder
Return the default order by that may need to be used if the query includes a many property.- Specified by:
getDefaultOrderBy
in interfaceIdBinder
-
getProperties
public BeanProperty[] getProperties()
-
getIdInValueExprDelete
public String getIdInValueExprDelete(int size)
Description copied from interface:IdBinder
Same as getIdInValueExpr but for delete by id.- Specified by:
getIdInValueExprDelete
in interfaceIdBinder
-
getIdInValueExpr
public String getIdInValueExpr(boolean not, int size)
Description copied from interface:IdBinder
Return the binding expression (like "?" or "(?,?)")for the Id.- Specified by:
getIdInValueExpr
in interfaceIdBinder
-
getIdValues
public Object[] getIdValues(EntityBean bean)
Description copied from interface:IdBinder
Return the id values for a given bean.- Specified by:
getIdValues
in interfaceIdBinder
-
getBindValues
public Object[] getBindValues(Object value)
Description copied from interface:IdBinder
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.
- Specified by:
getBindValues
in interfaceIdBinder
-
getIdForJson
public Object getIdForJson(EntityBean bean)
Convert from embedded bean to Map.- Specified by:
getIdForJson
in interfaceIdBinder
-
convertIdFromJson
public Object convertIdFromJson(Object value)
Convert back from a Map to embedded bean.- Specified by:
convertIdFromJson
in interfaceIdBinder
-
bindId
public void bindId(DefaultSqlUpdate sqlUpdate, Object value)
Description copied from interface:IdBinder
Bind the id value to a SqlUpdate statement.
-
bindId
public void bindId(DataBind dataBind, Object value) throws SQLException
Description copied from interface:IdBinder
Binds an id value to a prepared statement.- Specified by:
bindId
in interfaceIdBinder
- Throws:
SQLException
-
addIdInBindValues
public void addIdInBindValues(DefaultSqlUpdate sqlUpdate, Collection<?> values)
Description copied from interface:IdBinder
Binds multiple id value to an update.- Specified by:
addIdInBindValues
in interfaceIdBinder
-
addIdInBindValues
public void addIdInBindValues(SpiExpressionRequest request, Collection<?> values)
Description copied from interface:IdBinder
Binds multiple id value to a request.- Specified by:
addIdInBindValues
in interfaceIdBinder
-
readData
public Object readData(DataInput dataInput) throws IOException
Description copied from interface:IdBinder
Read the Id value from the binary DataInput.- Specified by:
readData
in interfaceIdBinder
- Throws:
IOException
-
writeData
public void writeData(DataOutput dataOutput, Object idValue) throws IOException
Description copied from interface:IdBinder
Write the Id value to binary DataOuput.- Specified by:
writeData
in interfaceIdBinder
- Throws:
IOException
-
loadIgnore
public void loadIgnore(DbReadContext ctx)
Description copied from interface:IdBinder
Ignore the appropriate number of scalar properties for this id.- Specified by:
loadIgnore
in interfaceIdBinder
-
read
public Object read(DbReadContext ctx) throws SQLException
Description copied from interface:IdBinder
Read the id value from the result set and return it.- Specified by:
read
in interfaceIdBinder
- Throws:
SQLException
-
readSet
public Object readSet(DbReadContext ctx, EntityBean bean) throws SQLException
Description copied from interface:IdBinder
Read the id value from the result set and set it to the bean also returning it.- Specified by:
readSet
in interfaceIdBinder
- Throws:
SQLException
-
appendSelect
public void appendSelect(DbSqlContext ctx, boolean subQuery)
Description copied from interface:IdBinder
Append to the select clause.- Specified by:
appendSelect
in interfaceIdBinder
-
getAssocIdInExpr
public String getAssocIdInExpr(String prefix)
Description copied from interface:IdBinder
Return the logical id in expression taking into account embedded id's.- Specified by:
getAssocIdInExpr
in interfaceIdBinder
-
getAssocOneIdExpr
public String getAssocOneIdExpr(String prefix, String operator)
Description copied from interface:IdBinder
Build a string of the logical expressions.Typically used to build a id = ? string.
- Specified by:
getAssocOneIdExpr
in interfaceIdBinder
-
getBindIdSql
public String getBindIdSql(String baseTableAlias)
Description copied from interface:IdBinder
Return the sql for binding the id to. This includes table alias and columns that make up the id.- Specified by:
getBindIdSql
in interfaceIdBinder
-
getBindIdInSql
public String getBindIdInSql(String baseTableAlias)
Description copied from interface:IdBinder
Return the sql for binding the id using an IN clause.- Specified by:
getBindIdInSql
in interfaceIdBinder
-
convertId
public Object convertId(Object idValue)
Description copied from interface:IdBinder
Cast or convert the Id value if necessary.
-
convertSetId
public Object convertSetId(Object idValue, EntityBean bean)
Description copied from interface:IdBinder
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.
- Specified by:
convertSetId
in interfaceIdBinder
-
cacheKey
public String cacheKey(Object value)
Description copied from interface:IdBinder
Return a key to use for bean caches given the id value.
-
cacheKeyFromBean
public String cacheKeyFromBean(EntityBean bean)
Description copied from interface:IdBinder
Return a key to use for bean caches given the bean.- Specified by:
cacheKeyFromBean
in interfaceIdBinder
-
-