Commit Graph

148 Commits

Author SHA1 Message Date
Juergen Hoeller
86ea3059b6 Polishing 2014-07-01 15:11:36 +02:00
Juergen Hoeller
c16032b98a Consistent declaration of private static final logger variables
Issue: SPR-11905
(cherry picked from commit 18131bf)
2014-07-01 12:09:29 +02:00
Juergen Hoeller
8a28645dd6 ResultSetWrappingSqlRowSet preserves first matching column per name (as defined in ResultSet's javadoc)
Issue: SPR-11786
(cherry picked from commit 0728e32)
2014-05-15 14:40:43 +02:00
Juergen Hoeller
1afdd9bd75 Polishing
(cherry picked from commit 02aca9c)
2014-04-30 00:10:58 +02:00
Juergen Hoeller
59cef3ce81 General defensiveness about the bootstrap ClassLoader (i.e. null ClassLoader)
Issue: SPR-11721
2014-04-28 00:26:18 +02:00
Juergen Hoeller
c9432ce499 JDBC 3.0 related javadoc overhaul
Issue: SPR-11600
(cherry picked from commit 3fef358)
2014-04-17 21:31:45 +02:00
Sam Brannen
03ae8eeb95 Make EOF_STATEMENT_SEPARATOR XML friendly
Changed the value of ScriptUtils.EOF_STATEMENT_SEPARATOR from
"<<< END OF SCRIPT >>>" to "^^^ END OF SCRIPT ^^^" so that the angle
brackets do not have to be escaped in XML configuration files.

Issue: SPR-11687
(cherry picked from commit 1753f5d1ca)
2014-04-11 18:27:59 +02:00
Sam Brannen
9230b38aea Support EOF as statement separator in SQL scripts
Prior to Spring Framework 4.0.3, it was possible to supply a bogus
statement separator (i.e., a separator string that does not exist in
the configured SQL scripts) to ResourceDatabasePopulator with the side
effect that the entire contents of a script file would be interpreted
as a single SQL statement.

This undocumented feature was never intentional; however, some
developers came to rely on it. Unfortunately, changes made in
conjunction with SPR-9531 and SPR-11560 caused such scenarios to no
longer work.

This commit introduces first-class support for executing scripts which
contain a single statement that spans multiple lines but is not
followed by an explicit statement separator.

Specifically, ScriptUtils.EOF_STATEMENT_SEPARATOR may now be specified
as a 'virtual' statement separator to denote that a script contains a
single statement and no actual separator.

Issue: SPR-11687
(cherry picked from commit cc0ae3a881)
2014-04-11 18:25:06 +02:00
Stephane Nicoll
4cd818b9e4 Harmonize log configuration
Prior to this commit, the codebase was using a mix of log4j.xml
and log4j.properties for test-related logging configuration. This
can be an issue as log4j takes the xml variant first when looking
for a default bootstrap configuration.

In practice, some modules declaring the properties variant were
taking the xml variant configuration from another module.

The general structure of the configuration has also been
harmonized to provide a standard console output as well as an
easy way to enable trace logs for the current module.
2014-03-20 09:43:29 -07:00
Sam Brannen
8aefcb9a55 Set DB_CLOSE_ON_EXIT=false in H2EmbeddedDbConfig
This commit sets the DB_CLOSE_ON_EXIT flag to false for embedded H2
databases loaded using H2EmbeddedDatabaseConfigurer (i.e., via Spring's
<jdbc:embedded-database /> XML namespace, EmbeddedDatabaseBuilder,
EmbeddedDatabaseFactory, and EmbeddedDatabaseFactoryBean).

Issue: SPR-11573
2014-03-19 01:22:46 +01:00
Sam Brannen
dc6d67510d Improve configurability of EmbeddedDatabaseBuilder
This commit improves the configurability of EmbeddedDatabaseBuilder by
exposing the following new configuration methods.

 - setDataSourceFactory(DataSourceFactory)
 - addScripts(String...)
 - setScriptEncoding(String)
 - setSeparator(String)
 - setCommentPrefix(String)
 - setBlockCommentStartDelimiter(String)
 - setBlockCommentEndDelimiter(String)
 - continueOnError(boolean)
 - ignoreFailedDrops(boolean)

If more fine grained control over the configuration of the embedded
database is required, users are recommended to use
EmbeddedDatabaseFactory with a ResourceDatabasePopulator and forego use
of the builder.

Issue: SPR-11410
2014-03-18 23:56:31 +01:00
Sam Brannen
34fe252acd Polish Javadoc for embedded database support 2014-03-18 23:56:31 +01:00
Sam Brannen
42690a9a9e Overhaul Javadoc for embedded database support 2014-03-18 12:54:40 +01:00
Sam Brannen
c61d62ef4b Improve DataSourceInitializer Javadoc and implementation 2014-03-18 12:54:02 +01:00
Sam Brannen
87e58a6d7b Improve Javadoc for DatabasePopulator 2014-03-18 12:52:59 +01:00
Sam Brannen
92eb99a5ab Favor ScriptException over SQLException
In ScriptUtils and related classes, SQLExceptions are now caught and
wrapped in ScriptExceptions wherever feasible.

Affected "throws" declarations have also been revised as appropriate.

Issue: SPR-11564
2014-03-17 16:05:09 +01:00
Sam Brannen
fbd25467c4 Introduce SQL script exception hierarchy
This commit continues the work began in SPR-9531 as follows.

 - ScriptException now extends DataAccessException.

 - DatabasePopulator.populate() now explicitly throws ScriptException.

 - Introduced UncategorizedScriptException.

 - DatabasePopulatorUtils.execute() now throws an
   UncategorizedScriptException instead of a
   DataAccessResourceFailureException.

Issue: SPR-11564
2014-03-17 12:26:32 +01:00
Sam Brannen
cae50c3a2d Polishing 2014-03-16 17:34:01 +01:00
Sam Brannen
bb67cd4657 Fix regression for newline separators in SQL scripts
Changes made in conjunction with SPR-9531, introduced a regression with
regard to support for using a single newline character as the statement
separator within SQL scripts. Investigation of the cause of this issue
resulted in the discovery of another, similar issue: support for
multiple newlines as a statement separator has been broken for years
but has gone unnoticed until now.

The reason that both of these issues have gone unnoticed is a result of
the fact that the test suite only executes SQL script integration tests
against HSQL DB, and HSQL does not care if two statements occur on the
same line; whereas, the H2 database will throw an exception if multiple
statements are included on the same line when executing an update.

This commit addresses both of these issues and provides further
enhancements to Spring's SQL script support as follows.

 - ScriptUtils now properly checks if the supplied script contains the
   custom statement separator or default separator before falling back
   to the 'fallback' separator (i.e., newline).

 - Introduced FALLBACK_STATEMENT_SEPARATOR constant in ScriptUtils.

 - ScriptUtils.readScript() no longer omits empty lines from the input
   file since a statement separator string may in fact be composed of
   multiple newline characters.

 - Introduced overloaded variants of splitSqlScript() and
   executeSqlScript() in ScriptUtils with smaller argument lists for
   common use cases.

 - Extracted AbstractDatabasePopulatorTests from DatabasePopulatorTests
   and introduced concrete HsqlDatabasePopulatorTests and
   H2DatabasePopulatorTests subclasses for testing against HSQL and H2.

 - Split ScriptUtilsTests into ScriptUtilsUnitTests and
   ScriptUtilsIntegrationTests for faster builds.

Issue: SPR-11560
2014-03-16 16:41:08 +01:00
Sam Brannen
01b2f67f11 Introduce constructors in ResourceDatabasePopulator
Issue: SPR-9531
2014-03-13 13:45:05 +01:00
Sam Brannen
2bfd6ddcf4 Refactor SQL script support
This commit continues the work in the previous commit as follows:

 - Introduced an exception hierarchy for exceptions related to SQL
   scripts, with ScriptException as the base.

 - CannotReadScriptException and ScriptStatementFailedException now
   extend ScriptException.

 - Introduced ScriptParseException, used by ScriptUtils.splitSqlScript().

 - DatabasePopulatorUtils.execute() now explicitly throws a
   DataAccessException.

 - Polished Javadoc in ResourceDatabasePopulator.

 - Overhauled Javadoc in ScriptUtils and documented all constants.

 - Added missing @author tags for original authors in ScriptUtils and
   ScriptUtilsTests.

 - ScriptUtils.splitSqlScript() now asserts preconditions.

 - Deleted superfluous methods in ScriptUtils and changed method
   visibility to private or package private as appropriate.

 - Deleted the ScriptStatementExecutor introduced in the previous
   commit; ScriptUtils.executeSqlScript() now accepts a JDBC Connection;
   JdbcTestUtils, AbstractTransactionalJUnit4SpringContextTests, and
   AbstractTransactionalTestNGSpringContextTests now use
   DatabasePopulatorUtils to execute a ResourceDatabasePopulator instead
   of executing a script directly via ScriptUtils.

 - Introduced JdbcTestUtilsIntegrationTests.

Issue: SPR-9531
2014-03-13 12:00:01 +01:00
cbaldwin74
e5c17560db Support multi-line comments in SQL scripts
Prior to this commit neither ResourceDatabasePopulator nor
JdbcTestUtils properly supported multi-line comments (e.g., /* ... */).
Secondarily there has developed a significant amount of code
duplication in these two classes that has led to maintenance issues
over the years.

This commit addresses these issues as follows:

 - Common code has been extracted from ResourceDatabasePopulator and
   JdbcTestUtils and moved to a new ScriptUtils class in the
   spring-jdbc module.

 - Relevant test cases have been migrated from JdbcTestUtilsTests to
   ScriptUtilsTests.

 - ScriptUtils.splitSqlScript() has been modified to ignore multi-line
   comments in scripts during processing.

 - ResourceDatabasePopulator supports configuration of the start and end
   delimiters for multi-line (block) comments.

 - A new test case was added to ScriptUtilsTests for the new multi-line
   comment support.

Issue: SPR-9531
2014-03-13 10:51:08 +01:00
Juergen Hoeller
473061ec1e Added explicit note on thread safety to JdbcTemplate variants
Issue: SPR-11478
2014-02-28 19:00:31 +01:00
Juergen Hoeller
cead06a3d9 Polishing 2014-02-12 00:12:52 +01:00
Sam Brannen
c335e99e3f Remove trailing whitespace from source code 2014-02-08 17:30:39 +01:00
Juergen Hoeller
8c0e3040c2 Polishing 2014-02-07 18:06:13 +01:00
Juergen Hoeller
749b65b0b2 Polishing 2014-02-07 17:42:37 +01:00
Juergen Hoeller
8a6b095204 Polishing
Issue: SPR-11386
2014-02-04 17:41:42 +01:00
Juergen Hoeller
60c1905cdd Introduced "spring.jdbc.getParameterType.ignore" property
Issue: SPR-11386
2014-02-04 16:44:08 +01:00
Sam Brannen
b8ed2f4967 Ensure all tests are executed in the Gradle build
Prior to this commit several test classes named "*Test" were not
recognized as tests by the Gradle build. This is due to the configured
inclusion of '**/*Tests.*' which follows Spring's naming convention for
test classes.

This commit addresses this issue by:

 - Renaming real test classes consistently to "*Tests".
 - Renaming internal test classes to "*TestCase".
 - Renaming @WebTest to @WebTestStereotype.
 - Disabling broken tests in AnnoDrivenStaticEntityMockingControlTest.
 - Modifying the Gradle build configuration so that classes ending in
   either "*Tests" or "*Test" are considered test classes.

Issue: SPR-11384
2014-02-03 23:16:47 +01:00
Sam Brannen
8c3868a8dd Polish Javadoc for EmbeddedDatabaseFactory 2014-01-31 13:33:55 +01:00
Juergen Hoeller
c2303854d1 Polishing
Issue: SPR-11372
2014-01-31 13:17:55 +01:00
Juergen Hoeller
e3017c30bb ResourceDatabasePopulator's setScripts takes varargs 2013-12-23 22:00:30 +01:00
Juergen Hoeller
d032c20a54 Polishing
Issue: SPR-10469
2013-12-23 21:59:21 +01:00
Juergen Hoeller
b4d6e27fb3 Upgraded embedded Derby support to 10.6+ and build to 10.10
Issue: SPR-10469
2013-12-23 21:58:42 +01:00
Juergen Hoeller
74c679eb2f Polishing 2013-12-17 18:21:04 +01:00
Juergen Hoeller
3ff3805ed6 Fixed extractOutputParameters to properly extract ResultSet in all cases
Issue: SPR-11076
2013-12-11 12:28:54 +01:00
Juergen Hoeller
2d2226baf6 Added 546 to Sybase data integrity violation codes
Issue: SPR-11097
2013-12-11 12:01:53 +01:00
Juergen Hoeller
be63c07b2e Polishing 2013-12-10 13:26:52 +01:00
Juergen Hoeller
4c8a7899f2 Optimized use of JDBC 3.0 ParameterMetaData.getParameterType, caching information about drivers which do not support that feature
Issue: SPR-11100
2013-12-10 01:38:57 +01:00
Phillip Webb
043a41e382 Consistent whitespace after imports
Update code to have a consistent number of new-line characters after
import statements.
2013-11-26 15:14:43 -08:00
Juergen Hoeller
1e6f2e79b9 Adapted getXmlAsSource implementation to avoid compilation failure in IntelliJ IDEA 2013-11-26 01:41:54 +01:00
Eric Dahl
e9f78f6043 Fix various typos
Fix a variety of typos throughout the project, primarily in
comments (javadoc or otherwise) but also in a handful of log messages
and a couple exception messages.

ISSUE: SPR-11123
2013-11-25 15:58:27 -08:00
Phillip Webb
59002f2456 Fix remaining compiler warnings
Fix remaining Java compiler warnings, mainly around missing
generics or deprecated code.

Also add the `-Werror` compiler option to ensure that any future
warnings will fail the build.

Issue: SPR-11064
2013-11-25 12:52:42 -08:00
Phillip Webb
d9c4470461 Upgrade to HSQLDB 2.3.1
Replace `hsqldb:hsqldb:1.8.0.10` with `org.hsqldb:hsqldb:2.3.1` and
fix breaking tests.

Issue: SPR-10947
2013-11-21 15:48:17 -08:00
Alex Yursha
6a1ca41cb7 Put accidentally deleted LF in place 2013-11-09 01:57:27 +03:00
Alex Yursha
6900645d59 Fix a typo in package description 2013-11-09 01:26:59 +03:00
Juergen Hoeller
13ed423387 Polished exception messages
Issue: SPR-11042
2013-11-01 23:07:50 +01:00
Juergen Hoeller
1dc7ff8604 Avoid unnecessary char[] allocation in NamedParameterUtils
Issue: SPR-11042
2013-11-01 22:38:55 +01:00
Sam Brannen
7ca09d7e3d Polish NamedParameterUtils
- Fixed typos in Javadoc
- Formatted Javadoc
2013-10-29 23:44:53 +01:00