Interface Crud<T,K>

Type Parameters:
T - the target type
K - the key type
All Known Implementing Classes:
DefaultCrud, LazyCrud, MultiRowsBatchInsertCrud

public interface Crud<T,K>
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    create(Connection connection, Collection<T> values)
    insert values into the db through the specified connection.
    <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
    RH
    create(Connection connection, Collection<T> values, RH keyConsumer)
    insert values into the db through the specified connection.
    void
    create(Connection connection, T value)
    insert value into the db through the specified connection.
    <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
    RH
    create(Connection connection, T value, RH keyConsumer)
    insert value into the db through the specified connection.
    void
    createOrUpdate(Connection connection, Collection<T> values)
    UPSERT only supported on Mysql
    <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
    RH
    createOrUpdate(Connection connection, Collection<T> values, RH keyConsumer)
    UPSERT only supported on Mysql and Postgres 9.5.
    void
    createOrUpdate(Connection connection, T value)
    UPSERT only supported on Mysql
    <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
    RH
    createOrUpdate(Connection connection, T value, RH keyConsumer)
    UPSERT only supported on Mysql and Postgres 9.5.
    void
    delete(Connection connection, Collection<K> keys)
    delete the objects with the specified keys.
    void
    delete(Connection connection, K key)
    delete the object with the specified key.
    <RH extends org.simpleflatmapper.util.CheckedConsumer<? super T>>
    RH
    read(Connection connection, Collection<K> keys, RH consumer)
    retrieve the objects with the specified keys and pass them to the consumer.
    read(Connection connection, K key)
    retrieve the object with the specified key.
    void
    update(Connection connection, Collection<T> values)
    update the objects.
    void
    update(Connection connection, T value)
    update the object.
    <P> SelectQuery<T,P>
    where(String whereClause, Type paramClass)
     
  • Method Details

    • create

      void create(Connection connection, T value) throws SQLException
      insert value into the db through the specified connection.
      Parameters:
      connection - the connection
      value - the value
      Throws:
      SQLException - if an error occurs
    • create

      void create(Connection connection, Collection<T> values) throws SQLException
      insert values into the db through the specified connection.
      Parameters:
      connection - the connection
      values - the values
      Throws:
      SQLException - if an error occurs
    • create

      <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH create(Connection connection, T value, RH keyConsumer) throws SQLException
      insert value into the db through the specified connection. Callback keyConsumer with the generated key if one was.
      Type Parameters:
      RH - the type of keyConsumer
      Parameters:
      connection - the connection
      value - the value
      keyConsumer - the key consumer
      Returns:
      the keyConsumer
      Throws:
      SQLException
    • create

      <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH create(Connection connection, Collection<T> values, RH keyConsumer) throws SQLException
      insert values into the db through the specified connection. Callback keyConsumer for the generated keys.
      Type Parameters:
      RH - the type of keyConsumer
      Parameters:
      connection - the connection
      values - the values
      keyConsumer - the key consumer
      Returns:
      the keyConsumer
      Throws:
      SQLException
    • read

      T read(Connection connection, K key) throws SQLException
      retrieve the object with the specified key.
      Parameters:
      connection - the connection
      key - the key
      Returns:
      the object or null if not found
      Throws:
      SQLException - if an error occurs
    • read

      <RH extends org.simpleflatmapper.util.CheckedConsumer<? super T>> RH read(Connection connection, Collection<K> keys, RH consumer) throws SQLException
      retrieve the objects with the specified keys and pass them to the consumer.
      Parameters:
      connection - the connection
      keys - the keys
      consumer - the handler that is callback for each row
      Throws:
      SQLException - if an error occurs
    • update

      void update(Connection connection, T value) throws SQLException
      update the object.
      Parameters:
      connection - the connection
      value - the object
      Throws:
      SQLException - if an error occurs
    • update

      void update(Connection connection, Collection<T> values) throws SQLException
      update the objects.
      Parameters:
      connection - the connection
      values - the objects
      Throws:
      SQLException - if an error occurs
    • delete

      void delete(Connection connection, K key) throws SQLException
      delete the object with the specified key.
      Parameters:
      connection - the connection
      key - the key
      Throws:
      SQLException - if an error occurs
    • delete

      void delete(Connection connection, Collection<K> keys) throws SQLException
      delete the objects with the specified keys.
      Parameters:
      connection - the connection
      keys - the keys
      Throws:
      SQLException - if an error occurs
    • createOrUpdate

      void createOrUpdate(Connection connection, T value) throws SQLException
      UPSERT only supported on Mysql
      Parameters:
      connection - the connection
      value - the value
      Throws:
      SQLException
      UnsupportedOperationException
    • createOrUpdate

      void createOrUpdate(Connection connection, Collection<T> values) throws SQLException
      UPSERT only supported on Mysql
      Parameters:
      connection - the connection
      values - the values to upsert
      Throws:
      SQLException
      UnsupportedOperationException
    • createOrUpdate

      <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH createOrUpdate(Connection connection, T value, RH keyConsumer) throws SQLException
      UPSERT only supported on Mysql and Postgres 9.5. Used the callback with caution has Mysql will return an incremented id event for when no insert actually occurred.
      Type Parameters:
      RH - the keyConsumer type
      Parameters:
      connection - the connection
      value - the value to upsert
      keyConsumer - generated key consumer
      Returns:
      the keyConsumer
      Throws:
      SQLException
    • createOrUpdate

      <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH createOrUpdate(Connection connection, Collection<T> values, RH keyConsumer) throws SQLException
      UPSERT only supported on Mysql and Postgres 9.5. Used the callback with caution has Mysql will return an incremented id event for when no insert actually occurred.
      Type Parameters:
      RH - the keyConsumer type
      Parameters:
      connection - the connection
      values - the values to insert
      keyConsumer - generated key consumer
      Returns:
      the keyConsumer
      Throws:
      SQLException
    • where

      <P> SelectQuery<T,P> where(String whereClause, Type paramClass)