Class ConnectedCrud<T,K>

java.lang.Object
org.simpleflatmapper.jdbc.ConnectedCrud<T,K>
Type Parameters:
T - the target type
K - the key type

public class ConnectedCrud<T,K> extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
    ConnectedCrud(TransactionTemplate transactionTemplate, Crud<T,K> delegate)
     
  • Method Summary

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

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

  • Method Details

    • create

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

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

      public <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH create(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:
      value - the value
      keyConsumer - the key consumer
      Returns:
      the keyConsumer
      Throws:
      SQLException
    • create

      public <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH create(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:
      values - the values
      keyConsumer - the key consumer
      Returns:
      the keyConsumer
      Throws:
      SQLException
    • read

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

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

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

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

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

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

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

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

      public <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH createOrUpdate(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:
      value - the value to upsert
      keyConsumer - generated key consumer
      Returns:
      the keyConsumer
      Throws:
      SQLException
    • createOrUpdate

      public <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH createOrUpdate(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:
      values - the values to insert
      keyConsumer - generated key consumer
      Returns:
      the keyConsumer
      Throws:
      SQLException
    • crud

      public Crud<T,K> crud()
    • where

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