Skip to content

@DisableQueriesWithoutBindParameters

Jean Bisutti edited this page Nov 17, 2020 · 5 revisions

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

Bind parameters is 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