public interface DbmsOperationHandler
Dbms
for when running queries.Modifier and Type | Method and Description |
---|---|
default void |
configureSelect(PreparedStatement statement)
Configures a select statement for optimum read performance.
|
default void |
configureSelect(ResultSet resultSet)
Configures a ResultSet for optimum read performance.
|
Array |
createArray(Dbms dbms,
String typeName,
Object[] elements)
Factory method for creating Array objects.
|
Blob |
createBlob(Dbms dbms)
Constructs an object that implements the
Blob interface. |
Clob |
createClob(Dbms dbms)
Constructs an object that implements the
Clob interface. |
NClob |
createNClob(Dbms dbms)
Constructs an object that implements the
NClob interface. |
SQLXML |
createSQLXML(Dbms dbms)
Constructs an object that implements the
SQLXML interface. |
Struct |
createStruct(Dbms dbms,
String typeName,
Object[] attributes)
Factory method for creating Struct objects.
|
void |
executeDelete(Dbms dbms,
String sql,
List<?> values)
Executes an SQL delete command.
|
<ENTITY> void |
executeInsert(Dbms dbms,
String sql,
List<?> values,
Collection<Field<ENTITY>> generatedKeyFields,
Consumer<List<Long>> generatedKeyConsumer)
Executes an SQL update command.
|
<T> Stream<T> |
executeQuery(Dbms dbms,
String sql,
List<?> values,
SqlFunction<ResultSet,T> rsMapper)
Eagerly executes a SQL query and subsequently maps each row in the
ResultSet using a provided mapper and return a stream of the
mapped objects. |
default <T> Stream<T> |
executeQuery(Dbms dbms,
String sql,
SqlFunction<ResultSet,T> rsMapper)
Eagerly executes a SQL query and subsequently maps each row in the
ResultSet using a provided mapper and return a Stream of the mapped
objects.
|
<T> AsynchronousQueryResult<T> |
executeQueryAsync(Dbms dbms,
String sql,
List<?> values,
SqlFunction<ResultSet,T> rsMapper,
ParallelStrategy parallelStrategy)
Lazily Executes a SQL query and subsequently maps each row in the
ResultSet using a provided mapper and return a stream of the
mapped objects. |
void |
executeUpdate(Dbms dbms,
String sql,
List<?> values)
Executes an SQL update command.
|
<ENTITY> void |
handleGeneratedKeys(PreparedStatement ps,
com.speedment.runtime.core.internal.manager.sql.SqlInsertStatement<ENTITY> sqlStatement) |
default <T> Stream<T> executeQuery(Dbms dbms, String sql, SqlFunction<ResultSet,T> rsMapper)
empty
stream is returned.T
- the type of the objects in the stream to returndbms
- the dbms to send it tosql
- the SQL command to executersMapper
- the mapper to use when iterating over the ResultSet<T> Stream<T> executeQuery(Dbms dbms, String sql, List<?> values, SqlFunction<ResultSet,T> rsMapper)
ResultSet
using a provided mapper and return a stream of the
mapped objects. The ResultSet
is eagerly consumed. If no objects
are present or if an SQLException
is thrown internally, an
empty
stream is returned.T
- the type of the objects in the stream to returndbms
- the dbms to send it tosql
- the non-null SQL command to executevalues
- non-null values to use for "?" parameters in the sql
commandrsMapper
- the non-null mapper to use when iterating over the
ResultSet
<T> AsynchronousQueryResult<T> executeQueryAsync(Dbms dbms, String sql, List<?> values, SqlFunction<ResultSet,T> rsMapper, ParallelStrategy parallelStrategy)
ResultSet
using a provided mapper and return a stream of the
mapped objects. The ResultSet
is lazily consumed so that the
stream will consume the ResultSet
as the objects are consumed. If
no objects are present, an empty
stream is returned.T
- the type of the objects in the Stream to returndbms
- the dbms to send it tosql
- the non-null SQL command to executevalues
- non-null List of objects to use for "?" parameters in the
SQL commandrsMapper
- the non-null mapper to use when iterating over the
ResultSet
parallelStrategy
- strategy to use if constructing a parallel stream<ENTITY> void executeInsert(Dbms dbms, String sql, List<?> values, Collection<Field<ENTITY>> generatedKeyFields, Consumer<List<Long>> generatedKeyConsumer) throws SQLException
ENTITY
- the type of the entity from which the fields comedbms
- the dbms to send it tosql
- the non-null SQL command to executevalues
- a non-null listgeneratedKeyFields
- list of the generated fieldsgeneratedKeyConsumer
- non-null List of objects to use for "?"
parameters in the SQL commandSQLException
- if an error occursvoid executeUpdate(Dbms dbms, String sql, List<?> values) throws SQLException
dbms
- the dbms to send it tosql
- the non-null SQL command to executevalues
- a non-null listSQLException
- if an error occursvoid executeDelete(Dbms dbms, String sql, List<?> values) throws SQLException
dbms
- the dbms to send it tosql
- the non-null SQL command to executevalues
- a non-null listSQLException
- if an error occursClob createClob(Dbms dbms) throws SQLException
Clob
interface. The
object returned initially contains no data. The
setAsciiStream
, setCharacterStream
and
setString
methods of the Clob
interface may be
used to add data to the Clob
.dbms
- the database to create it forClob
interfaceSQLException
- if an object that implements the Clob
interface can not be constructed, this method is called on a closed
connection or a database access error occurs.SQLFeatureNotSupportedException
- if the JDBC driver does not
support this data typeBlob createBlob(Dbms dbms) throws SQLException
Blob
interface. The
object returned initially contains no data. The
setBinaryStream
and setBytes
methods of the
Blob
interface may be used to add data to the
Blob
.dbms
- the database to create it forBlob
interfaceSQLException
- if an object that implements the Blob
interface can not be constructed, this method is called on a closed
connection or a database access error occurs.SQLFeatureNotSupportedException
- if the JDBC driver does not
support this data typeNClob createNClob(Dbms dbms) throws SQLException
NClob
interface.
The object returned initially contains no data. The
setAsciiStream
, setCharacterStream
and
setString
methods of the NClob
interface may be
used to add data to the NClob
.dbms
- the database to create it forNClob
interfaceSQLException
- if an object that implements the NClob
interface can not be constructed, this method is called on a closed
connection or a database access error occurs.SQLFeatureNotSupportedException
- if the JDBC driver does not
support this data typeSQLXML createSQLXML(Dbms dbms) throws SQLException
SQLXML
interface.
The object returned initially contains no data. The
createXmlStreamWriter
object and setString
method of the SQLXML
interface may be used to add data to
the SQLXML
object.dbms
- the database to create it forSQLXML
interfaceSQLException
- if an object that implements the SQLXML
interface can not be constructed, this method is called on a closed
connection or a database access error occurs.SQLFeatureNotSupportedException
- if the JDBC driver does not
support this data typeArray createArray(Dbms dbms, String typeName, Object[] elements) throws SQLException
Note: When createArrayOf
is used to create an array
object that maps to a primitive data type, then it is
implementation-defined whether the Array
object is an array
of that primitive data type or an array of Object
.
Note: The JDBC driver is responsible for mapping the elements
Object
array to the default JDBC SQL type defined in
java.sql.Types for the given class of Object
. The default
mapping is specified in Appendix B of the JDBC specification. If the
resulting JDBC type is not the appropriate type for the given typeName
then it is implementation defined whether an SQLException
is
thrown or the driver supports the resulting conversion.
dbms
- the database to create it fortypeName
- the SQL name of the type the elements of the array map
to. The typeName is a database-specific name which may be the name of a
built-in type, a user-defined type or a standard SQL type supported by
this database. This is the value returned by
Array.getBaseTypeName
elements
- the elements that populate the returned objectSQLException
- if a database error occurs, the JDBC type is not
appropriate for the typeName and the conversion is not supported, the
typeName is null or this method is called on a closed connectionSQLFeatureNotSupportedException
- if the JDBC driver does not
support this data typeStruct createStruct(Dbms dbms, String typeName, Object[] attributes) throws SQLException
dbms
- the database to create it fortypeName
- the SQL type name of the SQL structured type that this
Struct
object maps to. The typeName is the name of a
user-defined type that has been defined for this database. It is the
value returned by Struct.getSQLTypeName
.attributes
- the attributes that populate the returned objectSQLException
- if a database error occurs, the typeName is null or
this method is called on a closed connectionSQLFeatureNotSupportedException
- if the JDBC driver does not
support this data typedefault void configureSelect(PreparedStatement statement) throws SQLException
statement
- to configureSQLException
- if the configuration failsdefault void configureSelect(ResultSet resultSet) throws SQLException
resultSet
- to configureSQLException
- if the configuration fails<ENTITY> void handleGeneratedKeys(PreparedStatement ps, com.speedment.runtime.core.internal.manager.sql.SqlInsertStatement<ENTITY> sqlStatement) throws SQLException
SQLException
Copyright © 2018 Speedment, Inc.. All rights reserved.