Skip to content

@DisableQueriesWithoutBindParameters

Jean Bisutti edited this page Nov 3, 2021 Β· 4 revisions

The test will fail if a query without bind parameters is found.

Bind parameters are an essential feature to prevent SQL injections and can help improve performance:

In the case of skewed data, sharing a query execution plan with several executions may not be the best choice, as explained in this article.

We recommend configuring DisableQueriesWithoutBindParameters annotation with a global scope to prevent SQL injections and because, most of the time, bind parameters have a positive effect on performance.

You can disable the global scope DisableQueriesWithoutBindParameters by adding EnableQueriesWithoutBindParameters annotation on specific methods.

πŸ”Ž Example

Configuration of DisableQueriesWithoutBindParameters with a global scope.

⚠️ The class implementing SpecifiableGlobalAnnotations has to be in the org.quickperf package.

package org.quickperf;

import org.quickperf.config.SpecifiableGlobalAnnotations;
import org.quickperf.sql.annotation.SqlAnnotationBuilder;

import java.lang.annotation.Annotation;
import java.util.Arrays;
import java.util.Collection;

public class QuickPerfConfiguration implements SpecifiableGlobalAnnotations {

    public Collection<Annotation> specifyAnnotationsAppliedOnEachTest() {

        return Arrays.asList(
                SqlAnnotationBuilder.disableQueriesWithoutBindParameters()
        );

    }

}

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