Skip to content

SQL annotations

Jean Bisutti edited this page Apr 28, 2019 · 317 revisions

@SqlSelectNumber

Parameters

Parameter Type Meaning Default value
value int Number of select requests 0

Example

    @SqlSelectNumber(1)
    @Test
    public void should_retrieve_all_cars() {	
     //...
    }

@SqlInsertNumber

Parameters

Parameter Type Meaning Default value
value int Number of insert requests 0

@SqlUpdateNumber

Parameters

Parameter Type Meaning Default value
value int Number of update requests 0

@SqlDeleteNumber

Parameter Type Meaning Default value
value int Number of delete requests 0

@MaxSqlSelect

With this annotation, the test will fail if the number of SELECT requests is greater than expected.

Parameters

Parameter Type Meaning Default value
value int Maximum number of selects 0

Example

    @MaxSqlSelect(1)
    @Test
    public void should_retrieve_all_cars() {	
     //...
    }

@MaxSqlInsert

With this annotation, the test will fail if the number of INSERT requests is greater than expected.

Parameters

Parameter Type Meaning Default value
value int Maximum number of inserts 0

@MaxSqlUpdate

With this annotation, the test will fail if the number of UPDATE requests is greater than expected.

Parameters

Parameter Type Meaning Default value
value int Maximum number of updates 0

@MaxSqlDelete

With this annotation, the test will fail if the number of DELETE requests is greater than expected.

Parameters

Parameter Type Meaning Default value
value int Maximum number of deletes 0

@MaxReturnedSqlColumns

With this annotation, the test will fail if the number of returned columns is greater than expected.

Parameters

Parameter Type Meaning Default value
value int Maximum number of returned columns 0

Example

    @MaxReturnedSqlColumns(5)

@DisableSqlCrossJoin

The cartesian product induced by a cross join can be very inefficient. Although most database engines will try to remove a cross join, we can decide to remove cross join to not have to check if a database engine version will really remove it.

@EnableSqlCrossJoin

To decide to enable a cross join in a specific case if you add @DisableSqlCrossJoin check for every test or at test class level.

@DisableExactlySameSqlSelects

@EnableExactlySameSqlSelects

@DisableSameSelectTypesWithDifferentParams

@EnableSameSelectTypesWithDifferentParams

@DisableSelectDistinct

@EnableSelectDistinct

@DisableLikeStartingWithWildcard

@EnableLikeStartingWithWildcard

@SqlBatch

Parameters

Parameter Type Meaning Default value
batchSize int JDBC batch size -

A 0 batch size means that JDBC batching is disabled.

Example

    @SqlBatch(batchSize = 30)

@DisplaySql

@DisplayAllSql

Annotations

πŸ‘‰ Β Core

πŸ‘‰ Β JVM

πŸ‘‰ Β SQL

πŸ‘‰ Β Scopes

πŸ‘‰ Β Create an annotation

Supported frameworks

πŸ‘‰ Β JUnit 4

πŸ‘‰ Β JUnit 5

πŸ‘‰ Β TestNG

πŸ‘‰ Β Spring

How to

πŸ‘‰ Β Detect and fix N+1 SELECT

Project examples

πŸ‘‰ Β Maven performance

πŸ‘‰ Β Spring Boot - JUnit 4

πŸ‘‰ Β Spring Boot - JUnit 5

πŸ‘‰ Β Micronaut Data - JUnit 5

πŸ‘‰ Β Micronaut - Spring - JUnit 5

πŸ‘‰ Β Quarkus - JUnit 5

Miscellaneous

πŸ‘‰ Β FAQ

πŸ‘‰ Β QuickPerf code

Clone this wiki locally