java.lang.Object
org.simpleflatmapper.jdbc.impl.DefaultCrud<T,K>
- All Implemented Interfaces:
Crud<T,K>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stringprotected final QueryPreparer<K>protected final booleanprotected final QueryPreparer<T>protected final JdbcMapper<K>protected final KeyTupleQueryPreparer<K>protected final Stringprotected final JdbcMapper<T>protected final QueryPreparer<K>protected final SelectQueryWhereFactory<T>protected final QueryPreparer<T>protected final QueryPreparer<T> -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCrud(QueryPreparer<T> insertQueryPreparer, QueryPreparer<T> updateQueryPreparer, QueryPreparer<K> selectQueryPreparer, QueryPreparer<T> upsertQueryPreparer, KeyTupleQueryPreparer<K> keyTupleQueryPreparer, JdbcMapper<T> selectQueryMapper, QueryPreparer<K> deleteQueryPreparer, JdbcMapper<K> keyMapper, CrudMeta meta, boolean hasGeneratedKeys, SelectQueryWhereFactory<T> selectQueryWhereFactory) -
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.protected <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>,QPT>
RHexecuteQueryPreparer(Connection connection, QPT value, RH keyConsumer, QueryPreparer<QPT> queryPreparer) protected <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>>
RHexecuteQueryPreparerInBatchMode(Connection connection, Collection<T> values, RH keyConsumer, QueryPreparer<T> queryPreparer) protected voidhandleGeneratedKeys(org.simpleflatmapper.util.CheckedConsumer<? super K> keyConsumer, PreparedStatement preparedStatement) <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>
-
Field Details
-
insertQueryPreparer
-
updateQueryPreparer
-
selectQueryPreparer
-
deleteQueryPreparer
-
upsertQueryPreparer
-
keyTupleQueryPreparer
-
selectQueryMapper
-
keyMapper
-
hasGeneratedKeys
protected final boolean hasGeneratedKeys -
selectQueryWhereFactory
-
selectFromTableWhere
-
deleteFromTableWhere
-
-
Constructor Details
-
DefaultCrud
public DefaultCrud(QueryPreparer<T> insertQueryPreparer, QueryPreparer<T> updateQueryPreparer, QueryPreparer<K> selectQueryPreparer, QueryPreparer<T> upsertQueryPreparer, KeyTupleQueryPreparer<K> keyTupleQueryPreparer, JdbcMapper<T> selectQueryMapper, QueryPreparer<K> deleteQueryPreparer, JdbcMapper<K> keyMapper, CrudMeta meta, boolean hasGeneratedKeys, SelectQueryWhereFactory<T> selectQueryWhereFactory)
-
-
Method Details
-
create
Description copied from interface:Crudinsert value into the db through the specified connection.- Specified by:
createin interfaceCrud<T,K> - Parameters:
connection- the connectionvalue- the value- Throws:
SQLException- if an error occurs
-
create
Description copied from interface:Crudinsert values into the db through the specified connection.- Specified by:
createin interfaceCrud<T,K> - Parameters:
connection- the connectionvalues- the values- Throws:
SQLException- if an error occurs
-
create
public <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH create(Connection connection, T value, RH keyConsumer) throws SQLException Description copied from interface:Crudinsert value into the db through the specified connection. Callback keyConsumer with the generated key if one was.- Specified by:
createin interfaceCrud<T,K> - Type Parameters:
RH- the type of keyConsumer- Parameters:
connection- the connectionvalue- the valuekeyConsumer- the key consumer- Returns:
- the keyConsumer
- Throws:
SQLException
-
create
public <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH create(Connection connection, Collection<T> values, RH keyConsumer) throws SQLException Description copied from interface:Crudinsert values into the db through the specified connection. Callback keyConsumer for the generated keys.- Specified by:
createin interfaceCrud<T,K> - Type Parameters:
RH- the type of keyConsumer- Parameters:
connection- the connectionvalues- the valueskeyConsumer- the key consumer- Returns:
- the keyConsumer
- Throws:
SQLException
-
read
Description copied from interface:Crudretrieve the object with the specified key.- Specified by:
readin interfaceCrud<T,K> - Parameters:
connection- the connectionkey- 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(Connection connection, Collection<K> keys, RH consumer) throws SQLException Description copied from interface:Crudretrieve the objects with the specified keys and pass them to the consumer.- Specified by:
readin interfaceCrud<T,K> - Parameters:
connection- the connectionkeys- the keysconsumer- the handler that is callback for each row- Throws:
SQLException- if an error occurs
-
update
Description copied from interface:Crudupdate the object.- Specified by:
updatein interfaceCrud<T,K> - Parameters:
connection- the connectionvalue- the object- Throws:
SQLException- if an error occurs
-
update
Description copied from interface:Crudupdate the objects.- Specified by:
updatein interfaceCrud<T,K> - Parameters:
connection- the connectionvalues- the objects- Throws:
SQLException- if an error occurs
-
delete
Description copied from interface:Cruddelete the object with the specified key.- Specified by:
deletein interfaceCrud<T,K> - Parameters:
connection- the connectionkey- the key- Throws:
SQLException- if an error occurs
-
delete
Description copied from interface:Cruddelete the objects with the specified keys.- Specified by:
deletein interfaceCrud<T,K> - Parameters:
connection- the connectionkeys- the keys- Throws:
SQLException- if an error occurs
-
createOrUpdate
Description copied from interface:CrudUPSERT only supported on Mysql- Specified by:
createOrUpdatein interfaceCrud<T,K> - Parameters:
connection- the connectionvalue- the value- Throws:
SQLException
-
createOrUpdate
Description copied from interface:CrudUPSERT only supported on Mysql- Specified by:
createOrUpdatein interfaceCrud<T,K> - Parameters:
connection- the connectionvalues- the values to upsert- Throws:
SQLException
-
createOrUpdate
public <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH createOrUpdate(Connection connection, T value, RH keyConsumer) throws SQLException Description copied from interface:CrudUPSERT 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.- Specified by:
createOrUpdatein interfaceCrud<T,K> - Type Parameters:
RH- the keyConsumer type- Parameters:
connection- the connectionvalue- the value to upsertkeyConsumer- generated key consumer- Returns:
- the keyConsumer
- Throws:
SQLException
-
createOrUpdate
public <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH createOrUpdate(Connection connection, Collection<T> values, RH keyConsumer) throws SQLException Description copied from interface:CrudUPSERT 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.- Specified by:
createOrUpdatein interfaceCrud<T,K> - Type Parameters:
RH- the keyConsumer type- Parameters:
connection- the connectionvalues- the values to insertkeyConsumer- generated key consumer- Returns:
- the keyConsumer
- Throws:
SQLException
-
where
-
executeQueryPreparerInBatchMode
protected <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>> RH executeQueryPreparerInBatchMode(Connection connection, Collection<T> values, RH keyConsumer, QueryPreparer<T> queryPreparer) throws SQLException - Throws:
SQLException
-
executeQueryPreparer
protected <RH extends org.simpleflatmapper.util.CheckedConsumer<? super K>,QPT> RH executeQueryPreparer(Connection connection, QPT value, RH keyConsumer, QueryPreparer<QPT> queryPreparer) throws SQLException - Throws:
SQLException
-
handleGeneratedKeys
protected void handleGeneratedKeys(org.simpleflatmapper.util.CheckedConsumer<? super K> keyConsumer, PreparedStatement preparedStatement) throws SQLException - Throws:
SQLException
-