- Type Parameters:
T- the target typeK- the key type
- All Known Implementing Classes:
DefaultCrud,LazyCrud,MultiRowsBatchInsertCrud
public interface Crud<T,K>
-
Method Summary
Modifier and TypeMethodDescriptionvoidcreate(Connection connection, Collection<T> values) insert values into the db through the specified connection.<RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
RHcreate(Connection connection, Collection<T> values, RH keyConsumer) insert values into the db through the specified connection.voidcreate(Connection connection, T value) insert value into the db through the specified connection.<RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
RHcreate(Connection connection, T value, RH keyConsumer) insert value into the db through the specified connection.voidcreateOrUpdate(Connection connection, Collection<T> values) UPSERT only supported on Mysql<RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
RHcreateOrUpdate(Connection connection, Collection<T> values, RH keyConsumer) UPSERT only supported on Mysql and Postgres 9.5.voidcreateOrUpdate(Connection connection, T value) UPSERT only supported on Mysql<RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
RHcreateOrUpdate(Connection connection, T value, RH keyConsumer) UPSERT only supported on Mysql and Postgres 9.5.voiddelete(Connection connection, Collection<K> keys) delete the objects with the specified keys.voiddelete(Connection connection, K key) delete the object with the specified key.<RH extends org.simpleflatmapper.util.CheckedConsumer<? super T>>
RHread(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.voidupdate(Connection connection, Collection<T> values) update the objects.voidupdate(Connection connection, T value) update the object.<P> SelectQuery<T,P>
-
Method Details
-
create
insert value into the db through the specified connection.- Parameters:
connection- the connectionvalue- the value- Throws:
SQLException- if an error occurs
-
create
insert values into the db through the specified connection.- Parameters:
connection- the connectionvalues- 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 connectionvalue- the valuekeyConsumer- 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 connectionvalues- the valueskeyConsumer- the key consumer- Returns:
- the keyConsumer
- Throws:
SQLException
-
read
retrieve the object with the specified key.- Parameters:
connection- the connectionkey- 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 connectionkeys- the keysconsumer- the handler that is callback for each row- Throws:
SQLException- if an error occurs
-
update
update the object.- Parameters:
connection- the connectionvalue- the object- Throws:
SQLException- if an error occurs
-
update
update the objects.- Parameters:
connection- the connectionvalues- the objects- Throws:
SQLException- if an error occurs
-
delete
delete the object with the specified key.- Parameters:
connection- the connectionkey- the key- Throws:
SQLException- if an error occurs
-
delete
delete the objects with the specified keys.- Parameters:
connection- the connectionkeys- the keys- Throws:
SQLException- if an error occurs
-
createOrUpdate
UPSERT only supported on Mysql- Parameters:
connection- the connectionvalue- the value- Throws:
SQLExceptionUnsupportedOperationException
-
createOrUpdate
UPSERT only supported on Mysql- Parameters:
connection- the connectionvalues- the values to upsert- Throws:
SQLExceptionUnsupportedOperationException
-
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 connectionvalue- the value to upsertkeyConsumer- 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 connectionvalues- the values to insertkeyConsumer- generated key consumer- Returns:
- the keyConsumer
- Throws:
SQLException
-
where
-