Package org.jdbi.v3.core.result
Class ResultProducers
- java.lang.Object
-
- org.jdbi.v3.core.result.ResultProducers
-
- All Implemented Interfaces:
JdbiConfig<ResultProducers>
public class ResultProducers extends java.lang.Object implements JdbiConfig<ResultProducers>
Commonly used ResultProducer implementations.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceResultProducers.ResultSetCreator
-
Field Summary
Fields Modifier and Type Field Description private booleanallowNoResults
-
Constructor Summary
Constructors Modifier Constructor Description ResultProducers()privateResultProducers(ResultProducers that)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description ResultProducersallowNoResults(boolean allowNoResults)Normally a query that doesn't return a result set throws an exception.ResultProducerscreateCopy()Returns a copy of this configuration object.static ResultBearingcreateResultBearing(java.util.function.Supplier<java.sql.PreparedStatement> preparedStatementSupplier, ResultProducers.ResultSetCreator resultSetCreator, StatementContext ctx)Create aResultBearinginstance backed by aResultSet.static ResultProducer<ResultBearing>returningGeneratedKeys(java.lang.String... generatedKeyColumnNames)Result producer that returns aResultBearingover the statement-generated keys.static ResultProducer<ResultBearing>returningResults()Result producer that returns aResultBearingover the statement result rows.static ResultProducer<java.lang.Integer>returningUpdateCount()Result producer that eagerly executes the statement, returning the update count-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jdbi.v3.core.config.JdbiConfig
setRegistry
-
-
-
-
Constructor Detail
-
ResultProducers
public ResultProducers()
-
ResultProducers
private ResultProducers(ResultProducers that)
-
-
Method Detail
-
returningUpdateCount
public static ResultProducer<java.lang.Integer> returningUpdateCount()
Result producer that eagerly executes the statement, returning the update count- Returns:
- update count
- See Also:
Statement.getUpdateCount()
-
returningResults
public static ResultProducer<ResultBearing> returningResults()
Result producer that returns aResultBearingover the statement result rows.- Returns:
- ResultBearing of result rows.
- See Also:
Statement.getResultSet()
-
returningGeneratedKeys
public static ResultProducer<ResultBearing> returningGeneratedKeys(java.lang.String... generatedKeyColumnNames)
Result producer that returns aResultBearingover the statement-generated keys.- Parameters:
generatedKeyColumnNames- optional list of generated key column names.- Returns:
- ResultBearing of generated keys
- See Also:
Statement.getGeneratedKeys()
-
createResultBearing
public static ResultBearing createResultBearing(java.util.function.Supplier<java.sql.PreparedStatement> preparedStatementSupplier, ResultProducers.ResultSetCreator resultSetCreator, StatementContext ctx)
Create aResultBearinginstance backed by aResultSet. This method can be used to create otherResultProducerinstances that manage aResultBearinginstance.- Parameters:
preparedStatementSupplier- Provides thePreparedStatementto obtain theResultSet.resultSetCreator- Creates aResultSetfrom aStatement.ctx- The statement context.- Returns:
- An instance of
ResultBearingthat is backed by theResultSet.
-
createCopy
public ResultProducers createCopy()
Description copied from interface:JdbiConfigReturns a copy of this configuration object. Changes to the copy should not modify the original, and vice-versa.- Specified by:
createCopyin interfaceJdbiConfig<ResultProducers>- Returns:
- a copy of this configuration object.
-
allowNoResults
public ResultProducers allowNoResults(boolean allowNoResults)
Normally a query that doesn't return a result set throws an exception. With this option, we will replace it with an empty result set instead.- Parameters:
allowNoResults- True if an emptyResultSetobject should be returned, false if aNoResultsExceptionshould be thrown.- Returns:
- this
-
-