java.lang.Object
org.simpleflatmapper.jdbc.ConnectedCrud<T,K>
- Type Parameters:
T- the target typeK- the key type
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate(Collection<T> values) insert values into the db through the specified connection.<RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
RHcreate(Collection<T> values, RH keyConsumer) insert values into the db through the specified connection.voidinsert value into the db through the specified connection.<RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
RHinsert value into the db through the specified connection.voidcreateOrUpdate(Collection<T> values) UPSERT only supported on Mysql<RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
RHcreateOrUpdate(Collection<T> values, RH keyConsumer) UPSERT only supported on Mysql and Postgres 9.5.voidcreateOrUpdate(T value) UPSERT only supported on Mysql<RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
RHcreateOrUpdate(T value, RH keyConsumer) UPSERT only supported on Mysql and Postgres 9.5.crud()voiddelete(Collection<K> keys) delete the objects with the specified keys.voiddelete the object with the specified key.<RH extends org.simpleflatmapper.util.CheckedConsumer<? super T>>
RHread(Collection<K> keys, RH consumer) retrieve the objects with the specified keys and pass them to the consumer.retrieve the object with the specified key.voidupdate(Collection<T> values) update the objects.voidupdate the object.<P> ConnectedSelectQuery<T,P>
-
Constructor Details
-
ConnectedCrud
-
-
Method Details
-
create
insert value into the db through the specified connection.- Parameters:
value- the value- Throws:
SQLException- if an error occurs
-
create
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 valuekeyConsumer- 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 valueskeyConsumer- the key consumer- Returns:
- the keyConsumer
- Throws:
SQLException
-
read
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 keysconsumer- the handler that is callback for each row- Throws:
SQLException- if an error occurs
-
update
update the object.- Parameters:
value- the object- Throws:
SQLException- if an error occurs
-
update
update the objects.- Parameters:
values- the objects- Throws:
SQLException- if an error occurs
-
delete
delete the object with the specified key.- Parameters:
key- the key- Throws:
SQLException- if an error occurs
-
delete
delete the objects with the specified keys.- Parameters:
keys- the keys- Throws:
SQLException- if an error occurs
-
createOrUpdate
UPSERT only supported on Mysql- Parameters:
value- the value- Throws:
SQLExceptionUnsupportedOperationException
-
createOrUpdate
UPSERT only supported on Mysql- Parameters:
values- the values to upsert- Throws:
SQLExceptionUnsupportedOperationException
-
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 upsertkeyConsumer- 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 insertkeyConsumer- generated key consumer- Returns:
- the keyConsumer
- Throws:
SQLException
-
crud
-
where
-