Annotation 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.
This annotation will be inherited from an enclosing test class by default. See
@NestedTestConfiguration
for details.
- Since:
- 4.1
- Author:
- Sam Brannen, Tadaya Tsuyukubo
- See Also:
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic enumEnumeration of modes that dictate how errors are handled while executing SQL statements.static enumEnumeration of modes that dictate whether SQL scripts should be executed within a transaction and what the transaction propagation behavior should be.
- 
Optional Element SummaryOptional ElementsModifier and TypeOptional ElementDescriptionThe end delimiter that identifies block comments within the SQL scripts.The start delimiter that identifies block comments within the SQL scripts.The prefix that identifies single-line comments within the SQL scripts.String[]The prefixes that identify single-line comments within the SQL scripts.The bean name of theDataSourceagainst which the scripts should be executed.The encoding for the supplied SQL scripts, if different from the platform encoding.The mode to use when an error is encountered while executing an SQL statement.The character string used to separate individual statements within the SQL scripts.The bean name of thePlatformTransactionManagerthat should be used to drive transactions.The mode to use when determining whether SQL scripts should be executed within a transaction.
- 
Element Details- 
dataSourceString dataSourceThe bean name of theDataSourceagainst which the scripts should be executed.The name is only required if there is more than one bean of type DataSourcein the test'sApplicationContext. If there is only one such bean, it is not necessary to specify a bean name.Defaults to an empty string, requiring that one of the following is true: - An explicit bean name is defined in a global declaration of
@SqlConfig.
- The data source can be retrieved from the transaction manager
by using reflection to invoke a public method named
getDataSource()on the transaction manager.
- There is only one bean of type DataSourcein the test'sApplicationContext.
- The DataSourceto use is named"dataSource".
 - See Also:
 - Default:
- ""
 
- An explicit bean name is defined in a global declaration of
- 
transactionManagerString transactionManagerThe bean name of thePlatformTransactionManagerthat should be used to drive transactions.The name is only used if there is more than one bean of type PlatformTransactionManagerin the test'sApplicationContext. If there is only one such bean, it is not necessary to specify a bean name.Defaults to an empty string, requiring that one of the following is true: - An explicit bean name is defined in a global declaration of
@SqlConfig.
- There is only one bean of type PlatformTransactionManagerin the test'sApplicationContext.
- TransactionManagementConfigurerhas been implemented to specify which- PlatformTransactionManagerbean should be used for annotation-driven transaction management.
- The PlatformTransactionManagerto use is named"transactionManager".
 - See Also:
 - Default:
- ""
 
- An explicit bean name is defined in a global declaration of
- 
transactionModeSqlConfig.TransactionMode transactionModeThe mode to use when determining whether SQL scripts should be executed within a transaction.Defaults to DEFAULT.Can be set to SqlConfig.TransactionMode.ISOLATEDto ensure that the SQL scripts are executed in a new, isolated transaction that will be immediately committed.- See Also:
 - Default:
- DEFAULT
 
- 
encodingString encodingThe encoding for the supplied SQL scripts, if different from the platform encoding.An empty string denotes that the platform encoding should be used. - Default:
- ""
 
- 
separatorString separatorThe character string used to separate individual statements within the SQL scripts.Implicitly defaults to ";"if not specified and falls back to"\n"as a last resort.May be set to ScriptUtils.EOF_STATEMENT_SEPARATORto signal that each script contains a single statement without a separator.- See Also:
 - Default:
- ""
 
- 
commentPrefixString commentPrefixThe prefix that identifies single-line comments within the SQL scripts.Implicitly defaults to "--".This attribute may not be used in conjunction with commentPrefixes, but it may be used instead ofcommentPrefixes.- See Also:
 - Default:
- ""
 
- 
commentPrefixesString[] commentPrefixesThe prefixes that identify single-line comments within the SQL scripts.Implicitly defaults to ["--"].This attribute may not be used in conjunction with commentPrefix, but it may be used instead ofcommentPrefix.- Since:
- 5.2
- See Also:
 - Default:
- {}
 
- 
blockCommentStartDelimiterString blockCommentStartDelimiterThe start delimiter that identifies block comments within the SQL scripts.Implicitly defaults to "/*".- See Also:
 - Default:
- ""
 
- 
blockCommentEndDelimiterString blockCommentEndDelimiterThe end delimiter that identifies block comments within the SQL scripts.Implicitly defaults to "*/".- See Also:
 - Default:
- ""
 
- 
errorModeSqlConfig.ErrorMode errorModeThe mode to use when an error is encountered while executing an SQL statement.Defaults to DEFAULT.- See Also:
 - Default:
- DEFAULT
 
 
-