Top Description Fields Constructors Methods
org.jooq.tools.jdbc

public Class MockResult

extends Object
Class Inheritance
Imports
java.sql.SQLException, .Statement, org.jooq.DSLContext, .Record, .Result

A mock result.

This type is used to wrap unified results of DDL and DML query executions. JDBC execution results can be summarised to two properties:

See MockDataProvider#execute(MockExecuteContext) for more details

Author
Lukas Eder
See Also
MockDataProvider

Field Summary

Modifier and TypeField and Description
public final Result<?>
data

The result data associated with this execution result.

public final SQLException
exception

The exception associated with this execution result.

public final int
rows

The number of affected rows for this execution result.

Constructor Summary

AccessConstructor and Description
public
MockResult()

Create a new MockResult.

public
MockResult(int rows)

Create a new MockResult.

public
MockResult(Record
The single record in this result. Record instances can be obtained from queries, instantiated from generated record classes, or created using DSLContext#newRecord(org.jooq.Field...) and other overloads.
data
)

Create a new MockResult.

public
MockResult(int
The number of affected rows
rows
,
Result<?>
The result data. Result instances can be obtained from queries, or created using DSLContext#newResult(org.jooq.Field...) and other overloads.
data
)

Create a new MockResult.

public

Method Summary

Modifier and TypeMethod and Description
public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

databack to summary
public final Result<?> data

The result data associated with this execution result.

This object describes the result data (including meta data).

If the given query execution did not provide any results (as in Statement#execute(String) == false), this may be null. This is not the same as producing an empty result, which can only be modelled by an empty Result, containing column information but no rows.

Note, that this can also be used to provide a result for Statement#getGeneratedKeys()
exceptionback to summary
public final SQLException exception

The exception associated with this execution result.

If present, the current result produces an exception.

rowsback to summary
public final int rows

The number of affected rows for this execution result.

This number corresponds to the value of Statement#getUpdateCount(). The following values are possible:

  • Positive numbers: the number of affected rows by a given query execution
  • 0: no rows were affected by a given query execution
  • -1: the row count is not applicable

Constructor Detail

MockResultback to summary
public MockResult()

Create a new MockResult.

This is a convenience constructor calling MockResult(-1, null).

See Also
MockDataProvider for details
MockResultback to summary
public MockResult(int rows)

Create a new MockResult.

This is a convenience constructor calling MockResult(rows, null).

See Also
MockDataProvider for details
MockResultback to summary
public MockResult(Record data)

Create a new MockResult.

This is a convenience constructor creating a MockResult with exactly one record.

Parameters
data:Record

The single record in this result. Record instances can be obtained from queries, instantiated from generated record classes, or created using DSLContext#newRecord(org.jooq.Field...) and other overloads.

See Also
MockDataProvider for details
MockResultback to summary
public MockResult(int rows, Result<?> data)

Create a new MockResult.

Parameters
rows:int

The number of affected rows

data:Result<?>

The result data. Result instances can be obtained from queries, or created using DSLContext#newResult(org.jooq.Field...) and other overloads.

See Also
MockDataProvider for details
MockResultback to summary
public MockResult(SQLException exception)

Method Detail

toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object.

Returns:String

a string representation of the object.

Annotations
@Override