Annotation Interface SqlConfig

@Target(TYPE) @Retention(RUNTIME) @Documented @Inherited public @interface SqlConfig
@SqlConfig defines metadata that is used to determine how to parse and execute SQL scripts configured via the @Sql annotation.

Configuration Scope

When declared as a class-level annotation on an integration test class, @SqlConfig serves as global configuration for all SQL scripts within the test class hierarchy. When declared directly via the config attribute of the @Sql annotation, @SqlConfig serves as local configuration for the SQL scripts declared within the enclosing @Sql annotation.

Default Values

Every attribute in @SqlConfig has an implicit default value which is documented in the javadocs of the corresponding attribute. Due to the rules defined for annotation attributes in the Java Language Specification, it is unfortunately not possible to assign a value of null to an annotation attribute. Thus, in order to support overrides of inherited global configuration, @SqlConfig attributes have an explicit default value of either "" for Strings, {} for arrays, or DEFAULT for Enums. This approach allows local declarations of @SqlConfig to selectively override individual attributes from global declarations of @SqlConfig by providing a value other than "", {}, or DEFAULT.

Inheritance and Overrides

Global @SqlConfig attributes are inherited whenever local @SqlConfig attributes do not supply an explicit value other than "", {}, or DEFAULT. Explicit local configuration therefore overrides global configuration.

As of Spring Framework 5.3, this annotation will be inherited from an enclosing test class by default. See @NestedTestConfiguration for details.

Sam Brannen, Tadaya Tsuyukubo
See Also: