Class EntityParameterBinder

java.lang.Object
tech.guilhermekaua.spigotboot.data.jdbc.repository.mapper.EntityParameterBinder

public class EntityParameterBinder extends Object
  • Constructor Details

    • EntityParameterBinder

      public EntityParameterBinder(EntityMetadata metadata)
  • Method Details

    • bindInsertParameters

      public int bindInsertParameters(PreparedStatement ps, Object entity, boolean skipIdentityId) throws SQLException
      Throws:
      SQLException
    • bindInsertParameters

      public int bindInsertParameters(PreparedStatement ps, Object entity) throws SQLException
      Throws:
      SQLException
    • bindUpdateParameters

      public int bindUpdateParameters(PreparedStatement ps, Object entity) throws SQLException
      Throws:
      SQLException
    • bindUpdateParameters

      public int bindUpdateParameters(PreparedStatement ps, Object entity, int additionalColumnsCount) throws SQLException
      Binds parameters for an UPDATE statement whose SET clause is ordered as: [non-id columns] [additionalColumnsCount FK placeholders] WHERE [id columns].

      Non-id columns are bound first. The additionalColumnsCount FK placeholder positions are skipped so that the id columns land at the correct WHERE offset. The method returns the index of the first FK placeholder so the caller can bind those values immediately after (e.g. via bindJoinColumnParameters).

      Parameters:
      additionalColumnsCount - number of extra (FK) placeholder positions that appear in the SET clause after the non-id columns and before the WHERE id placeholder(s)
      Returns:
      the bind index of the first FK placeholder (i.e. one past the last non-id column)
      Throws:
      SQLException
    • bindIdParameters

      public int bindIdParameters(PreparedStatement ps, Object id, int startIndex) throws SQLException
      Throws:
      SQLException
    • extractId

      public Object extractId(Object entity)
    • getIdColumns

      public List<ColumnMetadata> getIdColumns()