Interface IdBinder

All Known Implementing Classes:
IdBinderEmbedded, IdBinderSimple

public interface IdBinder
Binds id values to prepared statements.
  • Method Details

    • initialise

      void initialise()
      Initialise the binder.
    • idSelect

      String idSelect()
    • 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
    • beanProperty

      STreeProperty beanProperty()
      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.
    • size

      default int size()
      Return the number of properties that make up the id.
    • orderBy

      String orderBy()
      Return the default order by that may need to be used if the query includes a many property.
    • orderBy

      String orderBy(String pathPrefix, boolean ascending)
    • values

      Object[] values(EntityBean bean)
      Return the id values for a given bean.
    • bindValues

      Object[] bindValues(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.

    • convertForJson

      Object convertForJson(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.

    • convertFromJson

      Object convertFromJson(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.

    • assocExpr

      String assocExpr(String prefix, String operator)
      Build a string of the logical expressions.

      Typically used to build a id = ? string.

    • assocInExpr

      String assocInExpr(String prefix)
      Return the logical id in expression taking into account embedded id's.
    • bindId

      void bindId(io.ebeaninternal.server.bind.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.
    • addBindValues

      void addBindValues(DefaultSqlUpdate sqlUpdate, Collection<?> ids)
      Binds multiple id value to an update.
    • addBindValues

      void addBindValues(SpiExpressionBind request, Collection<?> ids)
      Binds multiple id value to a request.
    • bindInSql

      String bindInSql(String baseTableAlias)
      Return the sql for binding the id using an IN clause.
    • idInValueExpr

      String idInValueExpr(boolean not, int size)
      Return the binding expression (like "?" or "(?,?)")for the Id.
    • idInValueExprDelete

      String idInValueExprDelete(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.
    • bindEqSql

      String bindEqSql(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.

    • convertId

      Object convertId(Object idValue)
      Cast or convert the Id value if necessary.
    • cacheKey

      String cacheKey(Object idValue)
      Return a key to use for bean caches given the id value.
    • cacheKeyFromBean

      String cacheKeyFromBean(EntityBean bean)
      Return a key to use for bean caches given the bean.