@Target(value=TYPE)
@Retention(value=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.
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.
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 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
.
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.
Sql
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
blockCommentEndDelimiter
The end delimiter that identifies block comments within the SQL scripts.
|
java.lang.String |
blockCommentStartDelimiter
The start delimiter that identifies block comments within the SQL scripts.
|
java.lang.String |
commentPrefix
The prefix that identifies single-line comments within the SQL scripts.
|
java.lang.String |
dataSource
The bean name of the
DataSource against which the
scripts should be executed. |
java.lang.String |
encoding
The encoding for the supplied SQL scripts, if different from the platform
encoding.
|
SqlConfig.ErrorMode |
errorMode
The mode to use when an error is encountered while executing an
SQL statement.
|
java.lang.String |
separator
The character string used to separate individual statements within the
SQL scripts.
|
java.lang.String |
transactionManager
The bean name of the
PlatformTransactionManager that should be used to drive transactions. |
SqlConfig.TransactionMode |
transactionMode
The mode to use when determining whether SQL scripts should be
executed within a transaction.
|
public abstract java.lang.String dataSource
DataSource
against which the
scripts should be executed.
The name is only required if there is more than one bean of type
DataSource
in the test's ApplicationContext
. 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:
@SqlConfig
.
getDataSource()
on the transaction manager.
DataSource
in the test's
ApplicationContext
.DataSource
to use is named "dataSource"
.public abstract java.lang.String transactionManager
PlatformTransactionManager
that should be used to drive transactions.
The name is only used if there is more than one bean of type
PlatformTransactionManager
in the test's ApplicationContext
.
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:
@SqlConfig
.
PlatformTransactionManager
in
the test's ApplicationContext
.TransactionManagementConfigurer
has been implemented to specify which
PlatformTransactionManager
bean should be used for annotation-driven
transaction management.PlatformTransactionManager
to use is named
"transactionManager"
.public abstract SqlConfig.TransactionMode transactionMode
Defaults to DEFAULT
.
Can be set to SqlConfig.TransactionMode.ISOLATED
to ensure that the SQL
scripts are executed in a new, isolated transaction that will be immediately
committed.
SqlConfig.TransactionMode
public abstract java.lang.String encoding
An empty string denotes that the platform encoding should be used.
public abstract java.lang.String separator
Implicitly defaults to ";"
if not specified and falls back to
"\n"
as a last resort.
May be set to
ScriptUtils.EOF_STATEMENT_SEPARATOR
to signal that each script contains a single statement without a
separator.
public abstract java.lang.String commentPrefix
Implicitly defaults to "--"
.
ScriptUtils.DEFAULT_COMMENT_PREFIX
public abstract java.lang.String blockCommentStartDelimiter
Implicitly defaults to "/*"
.
public abstract java.lang.String blockCommentEndDelimiter
Implicitly defaults to "*/"
.
public abstract SqlConfig.ErrorMode errorMode
Defaults to DEFAULT
.
SqlConfig.ErrorMode