Class IdBinderSimple

java.lang.Object
io.ebeaninternal.server.deploy.id.IdBinderSimple
All Implemented Interfaces:
IdBinder

public final class IdBinderSimple extends Object implements IdBinder
Bind an Id where the Id is made of a single property (not embedded).
  • Constructor Details

    • IdBinderSimple

      public IdBinderSimple(BeanProperty idProperty, io.ebeaninternal.server.persist.platform.MultiValueBind multiValueBind)
  • Method Details

    • initialise

      public void initialise()
      Description copied from interface: IdBinder
      Initialise the binder.
      Specified by:
      initialise in interface IdBinder
    • idSelect

      public String idSelect()
      Specified by:
      idSelect in interface IdBinder
    • 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 interface IdBinder
    • orderBy

      public String orderBy(String pathPrefix, boolean ascending)
      Specified by:
      orderBy in interface IdBinder
    • buildRawSqlSelectChain

      public void buildRawSqlSelectChain(String prefix, List<String> selectChain)
      Specified by:
      buildRawSqlSelectChain in interface IdBinder
    • beanProperty

      public BeanProperty beanProperty()
      Description copied from interface: IdBinder
      Return the Id BeanProperty.
      Specified by:
      beanProperty in interface IdBinder
    • 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 interface IdBinder
    • 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 interface IdBinder
    • orderBy

      public String orderBy()
      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:
      orderBy in interface IdBinder
    • bindInSql

      public String bindInSql(String baseTableAlias)
      Description copied from interface: IdBinder
      Return the sql for binding the id using an IN clause.
      Specified by:
      bindInSql in interface IdBinder
    • bindEqSql

      public String bindEqSql(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:
      bindEqSql in interface IdBinder
    • values

      public Object[] values(EntityBean bean)
      Description copied from interface: IdBinder
      Return the id values for a given bean.
      Specified by:
      values in interface IdBinder
    • bindValues

      public Object[] bindValues(Object idValue)
      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:
      bindValues in interface IdBinder
    • idInValueExprDelete

      public String idInValueExprDelete(int size)
      Description copied from interface: IdBinder
      Same as getIdInValueExpr but for delete by id.
      Specified by:
      idInValueExprDelete in interface IdBinder
    • idInValueExpr

      public String idInValueExpr(boolean not, int size)
      Description copied from interface: IdBinder
      Return the binding expression (like "?" or "(?,?)")for the Id.
      Specified by:
      idInValueExpr in interface IdBinder
    • addBindValues

      public void addBindValues(DefaultSqlUpdate sqlUpdate, Collection<?> ids)
      Description copied from interface: IdBinder
      Binds multiple id value to an update.
      Specified by:
      addBindValues in interface IdBinder
    • addBindValues

      public void addBindValues(SpiExpressionBind request, Collection<?> values)
      Description copied from interface: IdBinder
      Binds multiple id value to a request.
      Specified by:
      addBindValues in interface IdBinder
    • convertForJson

      public Object convertForJson(EntityBean bean)
      Description copied from interface: IdBinder
      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.

      Specified by:
      convertForJson in interface IdBinder
    • convertFromJson

      public Object convertFromJson(Object value)
      Description copied from interface: IdBinder
      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.

      Specified by:
      convertFromJson in interface IdBinder
    • bindId

      public void bindId(DefaultSqlUpdate sqlUpdate, Object value)
      Description copied from interface: IdBinder
      Bind the id value to a SqlUpdate statement.
      Specified by:
      bindId in interface IdBinder
    • bindId

      public void bindId(io.ebeaninternal.server.bind.DataBind dataBind, Object value) throws SQLException
      Description copied from interface: IdBinder
      Binds an id value to a prepared statement.
      Specified by:
      bindId in interface IdBinder
      Throws:
      SQLException
    • writeData

      public void writeData(DataOutput os, Object value) throws IOException
      Description copied from interface: IdBinder
      Write the Id value to binary DataOuput.
      Specified by:
      writeData in interface IdBinder
      Throws:
      IOException
    • readData

      public Object readData(DataInput is) throws IOException
      Description copied from interface: IdBinder
      Read the Id value from the binary DataInput.
      Specified by:
      readData in interface IdBinder
      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 interface IdBinder
    • 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 interface IdBinder
      Throws:
      SQLException
    • 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 interface IdBinder
      Throws:
      SQLException
    • appendSelect

      public void appendSelect(DbSqlContext ctx, boolean subQuery)
      Description copied from interface: IdBinder
      Append to the select clause.
      Specified by:
      appendSelect in interface IdBinder
    • assocExpr

      public String assocExpr(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:
      assocExpr in interface IdBinder
    • assocInExpr

      public String assocInExpr(String prefix)
      Description copied from interface: IdBinder
      Return the logical id in expression taking into account embedded id's.
      Specified by:
      assocInExpr in interface IdBinder
    • convertId

      public Object convertId(Object idValue)
      Description copied from interface: IdBinder
      Cast or convert the Id value if necessary.
      Specified by:
      convertId in interface IdBinder
    • 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 interface IdBinder
    • cacheKey

      public String cacheKey(Object value)
      Description copied from interface: IdBinder
      Return a key to use for bean caches given the id value.
      Specified by:
      cacheKey in interface IdBinder
    • 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 interface IdBinder