Commit Graph

581 Commits

Author SHA1 Message Date
igor-suhorukov e381514b07 Collection.isEmpty() should be used to test for emptiness
Closes gh-1670
2018-02-09 10:11:44 +01:00
Juergen Hoeller ac7a699356 NamedParameterUtils.isParameterSeparator checks for non-ASCII characters
Issue: SPR-16472
2018-02-07 14:10:39 +01:00
Johnny Lim df3241e072 Polish SqlParameter.sqlTypesToAnonymousParameterList()
Closes gh-1657
2018-02-01 09:14:56 +01:00
Juergen Hoeller 9d0e62ef68 Javadoc format and related polishing 2018-01-22 11:43:21 +01:00
Juergen Hoeller 572c668726 Polishing 2018-01-19 21:30:37 +01:00
Juergen Hoeller 44fd2d96cc Restore original separator set (but keep new isParameterSeparator impl)
Issue: SPR-16340
2018-01-14 17:57:32 +01:00
Philippe Marschall 91e39d558f Use ArrayList instead of LinkedList for known size
Spring JDBC unlike other modules uses LinkedList instead of ArrayList
in several places. There is a large body of evidence suggesting that on
contemporary hardware ArrayList is both faster and has less overhead
than even in degenerate cases of empty lists [3] or unknown size.

There are two places in Spring JDBC where the size of the list is known
in advance and an ArrayList of the correct final size can be created

 [1] https://bugs.java.com/bugdatabase/view_bug.do?bug_id=8011200
 [2] http://cliffc.org/blog/2017/11/05/modern-hardware-performance-cache-lines/
 [3] https://bugs.openjdk.java.net/browse/JDK-8011200

Issue: SPR-16378
2018-01-14 17:45:32 +01:00
Juergen Hoeller c8bdb3c602 Polishing 2018-01-09 22:20:22 +01:00
Juergen Hoeller e43439c6c3 SqlParameterSource interface exposes parameter names
Includes default implementations of getSqlType and getTypeName.

Issue: SPR-16361
2018-01-09 22:19:46 +01:00
Juergen Hoeller b2322e58d9 Support for PostgreSQL array syntax
Includes efficient separator determination.

Issue: SPR-16340
2018-01-09 22:19:05 +01:00
Christoph Dreis 260ebeca3a Improve performance of some string operations
Issue: SPR-16293
2017-12-12 17:14:24 +01:00
Juergen Hoeller b55a2631ba NamedParameterJdbcTemplate provides accessor for classic JdbcTemplate
Issue: SPR-16241
2017-11-29 15:38:21 +01:00
Juergen Hoeller b1c657fa4b Consistent nullability in DataAccessUtils through nullableSingleResult
Issue: SPR-16225
2017-11-26 17:16:39 +01:00
sdeleuze 9f1d8517ba Polish Kotlin source code style 2017-11-21 15:59:23 +01:00
Juergen Hoeller a8b48848b9 SqlParameterSourceUtils.createBatch with Collection support
Issue: SPR-16215
2017-11-19 21:17:24 +01:00
benoit 667e0341fa Improve memory allocations when substituting named parameters.
Create the buffer with at least the original sql length to avoid
multiple re-allocations
Add a fast path if the original sql doesn't contain any parameters
2017-11-08 23:45:53 +01:00
Juergen Hoeller db050ac38c Polishing 2017-11-04 01:07:09 +01:00
jmaxwell e4c5b77de7 SPR-16154 - Correctly handle NVARCHAR, LONGNVARCHAR and NCLOBs 2017-11-03 14:49:32 -05:00
Juergen Hoeller ee7b928300 Upgrade to Derby 10.14.1.0 2017-10-26 21:26:31 +02:00
Juergen Hoeller 75bd516251 Refined TemporaryLobCreator null handling (from 4.3.x)
Issue: SPR-15656
2017-09-27 15:40:13 +02:00
Juergen Hoeller 9190b76ab9 Latest dependency updates (POI 3.17, Rome 1.8, EhCache 3.4, Caffeine 2.5.6, RxJava 2.1.4, Tomcat 8.5.21, JRuby 9.1.13, Rhino 1.7.7.2) 2017-09-23 11:28:19 +02:00
Juergen Hoeller 7ae59d0c2a Nullability refinements on private and static methods
Based on IntelliJ IDEA 2017.3 introspection results.

Issue: SPR-15756
2017-09-22 18:22:14 +02:00
Juergen Hoeller 215e5f5682 Defensively call getParameterType (which might fail for certain statements)
Issue: SPR-15977
2017-09-20 10:54:49 +02:00
Sebastien Deleuze 1bc93e3d0f Revisit nullability annotations
This commit introduces the following changes.

1) It adds a new Spring @NonNull annotation which allows to apply
@NonNullApi semantic on a specific element, like @Nullable does.
Combined with @Nullable, it allows partial null-safety support when
package granularity is too broad.

2) @Nullable and @NonNull can apply to ElementType.TYPE_USE in order
to be used on generic type arguments (SPR-15942).

3) Annotations does not apply to ElementType.TYPE_PARAMETER anymore
since it is not supported yet (applicability for such use case is
controversial and need to be discussed).

4) @NonNullApi does not apply to ElementType.FIELD anymore since in a
lot of use cases (private, protected) it is not part for the public API
+ its usage should remain opt-in. A dedicated @NonNullFields annotation
has been added in order to set fields default to non-nullable.

5) Updated Javadoc and reference documentation.

Issue: SPR-15756
2017-09-15 13:26:41 +02:00
Sam Brannen 4e81ee5fdf Verify support for H2 database aliases in SQL scripts
This commit introduces a test to demonstrate how to define an alias in
an SQL script executed against an embedded H2 database.

Issue: SPR-15896
2017-08-26 15:04:48 +01:00
Brian Clozel 397fd24849 Revert "Leverage Kotlin plugin dependency management"
This reverts commit 3e2f6c848a.
2017-08-22 21:29:39 +02:00
Sebastien Deleuze 3e2f6c848a Leverage Kotlin plugin dependency management 2017-08-22 17:35:57 +02:00
Brian Clozel 2eeb428e95 Move modules to independent build files
The main `build.gradle` file contains now only the common build
infrastructure; all module-specific build configurations have
been moved to their own build file.

Issue: SPR-15885
2017-08-21 14:41:55 +02:00
Stephane Nicoll f6e7fef236 Polish 2017-08-19 10:50:41 +02:00
Juergen Hoeller 47a7475898 Resolve remaining nullability warnings
Issue: SPR-15869
2017-08-18 00:15:46 +02:00
Sebastien Deleuze 73cf07e9a4 Fix overridden methods nullability
Issue: SPR-15869
2017-08-17 15:02:59 +02:00
Juergen Hoeller 6d6d772f31 Polishing 2017-07-20 00:14:56 +02:00
Juergen Hoeller 46eba3dbfa Nullability fine-tuning around declaration inconsistencies
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 22:22:20 +02:00
Juergen Hoeller 9fc4fb10b0 Nullability fine-tuning around bean properties
Issue: SPR-15720
Issue: SPR-15792
2017-07-19 11:43:58 +02:00
Sebastien Deleuze fb4ddb0746 Make getters and setters null-safety consistent
This commit ensure that null-safety is consistent between
getters and setters in order to be able to provide beans
with properties with a common type when type safety is
taken in account like with Kotlin.

It also add a few missing property level @Nullable
annotations.

Issue: SPR-15792
2017-07-19 09:07:56 +02:00
Sebastien Deleuze 7a171c6ae9 Fix Kotlin return types to match @Nullable annotations 2017-07-04 11:27:54 +02:00
Juergen Hoeller cc74a2891a @Nullable all the way: null-safety at field level
This commits extends nullability declarations to the field level, formalizing the interaction between methods and their underlying fields and therefore avoiding any nullability mismatch.

Issue: SPR-15720
2017-06-30 01:54:16 +02:00
Sebastien Deleuze 04d5a2951c Remove KClass based Kotlin extensions
Issue: SPR-15660
2017-06-13 18:43:59 +02:00
Stephane Nicoll 1ab678a2a3 Polish "Refactor iterator of Map with Java8's Map.forEach"
Closes gh-1459
2017-06-13 16:06:20 +02:00
diguage 1ef5f61ab2 Refactor iterator of Map with Java8's Map.forEach
See gh-1459
2017-06-13 16:06:20 +02:00
Stephane Nicoll fc64b8040f Polish "Replace relevant code with lambda"
Closes gh-1454
2017-06-13 09:42:20 +02:00
diguage 4b1478d830 Replace relevant code with lambda
See gh-1454
2017-06-13 08:55:38 +02:00
Juergen Hoeller 3ae84d6dd8 Consistent support for Charset/StandardCharsets in UriUtils etc
Issue: SPR-15613
2017-06-12 15:51:45 +02:00
diguage c1d44d9a34 Use the diamond syntax
Closes gh-1450
2017-06-12 09:19:06 +02:00
Sebastien Deleuze 86580b2358 Polishing 2017-06-09 01:49:56 +03:00
Sebastien Deleuze 8579ae66fc Add comprehensive tests of Kotlin extensions
This commit also removes extensions hidden by Java API (varargs).
2017-06-09 01:01:16 +03:00
Juergen Hoeller ee5fa2633a Protect against null return value from DataSource.getConnection()
Issue: SPR-15641
2017-06-08 22:51:41 +02:00
Juergen Hoeller f813712f5b Consistent use of @Nullable across the codebase (even for internals)
Beyond just formally declaring the current behavior, this revision actually enforces non-null behavior in selected signatures now, not tolerating null values anymore when not explicitly documented. It also changes some utility methods with historic null-in/null-out tolerance towards enforced non-null return values, making them a proper citizen in non-null assignments.

Some issues are left as to-do: in particular a thorough revision of spring-test, and a few tests with unclear failures (ignored as "TODO: NULLABLE") to be sorted out in a follow-up commit.

Issue: SPR-15540
2017-06-07 14:19:15 +02:00
Sebastien Deleuze 1f28825f9d Add more @Nullable parameters based on null usage
Issue: SPR-15540
2017-05-31 21:42:23 +02:00
Sebastien Deleuze b47d713e14 Add missing @Nullable annotations on parameters
Issue: SPR-15540
2017-05-31 16:56:08 +02:00
Sebastien Deleuze 87598f48e4 Introduce null-safety of Spring Framework API
This commit introduces 2 new @Nullable and @NonNullApi
annotations that leverage JSR 305 (dormant but available via
Findbugs jsr305 dependency and already used by libraries
like OkHttp) meta-annotations to specify explicitly
null-safety of Spring Framework parameters and return values.

In order to avoid adding too much annotations, the
default is set at package level with @NonNullApi and
@Nullable annotations are added when needed at parameter or
return value level. These annotations are intended to be used
on Spring Framework itself but also by other Spring projects.

@Nullable annotations have been introduced based on Javadoc
and search of patterns like "return null;". It is expected that
nullability of Spring Framework API will be polished with
complementary commits.

In practice, this will make the whole Spring Framework API
null-safe for Kotlin projects (when KT-10942 will be fixed)
since Kotlin will be able to leverage these annotations to
know if a parameter or a return value is nullable or not. But
this is also useful for Java developers as well since IntelliJ
IDEA, for example, also understands these annotations to
generate warnings when unsafe nullable usages are detected.

Issue: SPR-15540
2017-05-27 08:57:01 +02:00
Juergen Hoeller 0b118322b0 Polishing 2017-04-13 16:17:05 +02:00
Juergen Hoeller 9e55e8f8a6 Polishing 2017-04-12 18:07:14 +02:00
Juergen Hoeller 67ea4b3a05 package-info for repackaged libraries (and other polishing) 2017-04-06 14:10:46 +02:00
Juergen Hoeller af6f688196 Test for BeanPropertySqlParameterSource with collection
Issue: SPR-15390
2017-04-04 17:17:29 +02:00
Amey Jadiye 472954bbb7 Polish javadoc
Closes gh-1370
2017-04-02 08:06:57 +02:00
arturgspb 8db8c85b69 SPR-15382 Spring Jdbc add Postgresql ?| and ?& operators support 2017-03-27 11:46:55 +03:00
Juergen Hoeller e892e02f41 Polishing 2017-03-21 17:44:47 +01:00
Juergen Hoeller 79ea77908a Process NULLABLE column as integer instead of boolean
Issue: SPR-15333
2017-03-14 15:19:13 +01:00
Sebastien Deleuze 9963c4a495 Fix Kotlin warnings 2017-03-10 10:35:30 +01:00
Ruslan Pistriak 8417a73913 Polishing
Closes gh-1340
2017-02-25 16:50:02 +01:00
Juergen Hoeller 0f51ff5ebc Reset global rollback-only status when rolling back to savepoint
Issue: SPR-6568
2017-02-17 23:40:44 +01:00
Juergen Hoeller 0da8dee289 Polishing 2017-02-16 16:24:13 +01:00
Juergen Hoeller 8d707eb530 Polishing 2017-02-16 15:37:31 +01:00
Juergen Hoeller 599c1ba73e Polishing 2017-02-15 18:05:38 +01:00
Juergen Hoeller 07dd61eabd Drop NativeJdbcExtractor mechanism in favor of JDBC 4 unwrap
Issue: SPR-14670
2017-02-15 18:04:08 +01:00
Juergen Hoeller e9019cd7d1 Polishing 2017-02-10 10:56:40 +01:00
Juergen Hoeller c0f4d78ef9 Use Map.getOrDefault in getSqlType implementation
Issue: SPR-15238
2017-02-10 10:54:54 +01:00
Juergen Hoeller b630c9bea7 Clear synchronization before triggering afterCompletion callbacks
Issue: SPR-15194
Issue: SPR-11590
2017-02-10 10:39:33 +01:00
Juergen Hoeller caf11a49ff Drop unused LobCreator synchronization utilities
Issue: SPR-13827
2017-02-10 10:36:52 +01:00
Juergen Hoeller acf511ac0e Polishing 2017-02-02 20:11:06 +01:00
Juergen Hoeller 02195f5abf Support for read-only transactions through explicit SET TRANSACTION statement
Issue: SPR-15210
2017-02-02 20:06:28 +01:00
Mario Arias c33ad15b28 Add Kotlin JDBC extensions
Issue: SPR-15158
2017-01-31 16:44:35 +01:00
Juergen Hoeller 1b2dc3638f Revisit Assert to avoid single-arg assert methods (with refined messages)
Issue: SPR-15196
2017-01-30 22:15:55 +01:00
Juergen Hoeller 743ce2cda6 Polishing 2017-01-12 23:30:38 +01:00
Juergen Hoeller e19dff179e Polishing 2017-01-12 21:18:01 +01:00
Juergen Hoeller de4349792b GenericTableMetaDataProvider falls back to single schema as default
Issue: SPR-15090
2017-01-12 21:15:08 +01:00
Thomas Risberg 5c7aee7d38 Updating MySQLMaxValueIncrementer to not rely on MYISAM
We should no longer rely on MYISAM for the sequence table since this
engine might not always be available. After this change the storage
engine used by the sequence table can be MYISAM or INNODB since the
sequences are allocated using a new connection without being
affected by any other transactions that might be in progress.

To allow users to fall back on the original functionality of using
MYISAM tables for the incrementer, we add a `useNewConnection` flag to
indicate whether or not to use a new connection for the incrementer.
This flag defaults to true.

Issue: SPR-15107
2017-01-11 17:24:41 -05:00
Sam Brannen 9ed66bf2eb Clean up warnings across code base 2017-01-07 01:54:38 +01:00
Philippe Marschall 3f97ab183e Avoid use of double constructor of BigDecimal
Codacy warns about an Error Prone [1] use of the double constructor of
BigDecimal in tests. The reason given is that it is a source of
precision loss if the number does not have an exact double
representation. The recommendation is to use the String constructor of
BigDecimal instead as it does not require using a lossy argument.

This commit contains the following changes:

 - replace usage of the double constructor of BigDecimal with the
   String constructor of BigDecimal in JdbcTemplateQueryTests
 - update the copyright year

 [1] http://errorprone.info/bugpattern/BigDecimalLiteralDouble

Issue: SPR-15077
2017-01-04 09:29:48 +01:00
Philippe Marschall 35bd00beaf Remove String#toCharArray from ScriptUtils
ScriptUtils contains two calls to String#toCharArray for the sole
purpose to iterating over all chars in a String. Not only is this
unnecessary and can be replaced with String#charAt it also causes
additional allocator and heap pressure because String#toCharArray
rather than returning the backing array (which is gone in Java 9)
creates a copy.

This commit contains the following changes:

 - remove String#toCharArray from ScriptUtils and replace with
   String#charAt

Issue: SPR-15075
2017-01-03 17:57:22 +01:00
Juergen Hoeller 82c1c859d9 Polishing
(cherry picked from commit 9cb4de8)
2016-12-20 21:17:48 +01:00
mmoores 79c202ab14 Call getColumnRowMapper() to create the row mapper; prevents requirement to override extractReturnedResults(). 2016-12-14 07:48:32 -08:00
Juergen Hoeller e49813f2c4 Polishing 2016-12-12 22:49:40 +01:00
Juergen Hoeller b825528d01 SQLErrorCodesFactory provides unregisterDatabase method
This commit also migrates from a WeakHashMap to a ConcurrentReferenceHashMap, allowing for concurrent access to existing cache entries.

Issue: SPR-15006
2016-12-12 15:26:46 +01:00
Juergen Hoeller 278a6250e6 Explicit support for retrieving enum values
Issue: SPR-14990
2016-12-08 18:30:25 +01:00
Juergen Hoeller 80931b211c Shared DefaultConversionService instance for simple fallback purposes
Issue: SPR-14948
2016-11-24 15:29:17 +01:00
Juergen Hoeller 1f4c6de287 Polishing 2016-11-23 21:10:01 +01:00
Juergen Hoeller a0fee4657d JdbcUtils explicitly extracts SQL date/time for JSR-310 LocalDate/Time
Issue: SPR-14898
2016-11-22 14:52:21 +01:00
Juergen Hoeller ac80ac6f8b Consistent instanceof/casting of Class references 2016-10-30 21:40:27 +01:00
Juergen Hoeller 2f9ed5917b Polishing 2016-10-28 23:49:21 +02:00
Juergen Hoeller dc080cb1be Revised NoSuchBeanDefinitionException message and ResolvableType handling
Includes consistent quoting of qualified type names in related classes.

Issue: SPR-14831
2016-10-28 23:39:05 +02:00
Juergen Hoeller 71d83388d4 Test for multi-character delimiter
Issue: SPR-14808
2016-10-28 15:37:10 +02:00
Juergen Hoeller 2874066a97 DataSourceTransactionManager triggers flush callbacks on registered transaction synchronizations
Issue: SPR-14847
2016-10-28 15:23:57 +02:00
Juergen Hoeller 3726c6f18d Polishing 2016-10-21 12:26:27 +02:00
Philippe Marschall f7c79295f3 Fix NativeJdbcExtractors documentation
The documentation mentions various NativeJdbcExtractors that no longer
exist. To be specific CommonsDbcpNativeJdbcExtractor and
XAPoolNativeJdbcExtractor no longer exist.

This commit includes the following changes:

 * remove CommonsDbcpNativeJdbcExtractor references from Asciidoctor
 * remove CommonsDbcpNativeJdbcExtractor references from Javadoc
 * remove XAPoolNativeJdbcExtractor references from Asciidoctor

Issue: SPR-14810
Closes gh-1205
2016-10-15 11:56:57 +03:00
Philippe Marschall ae5b0c6fb5 Replace J2EE with Java EE
String with version 5 the name of Java Platform, Enterprise Edition
changed from J2EE to Java EE. However a lot of the documentation still
uses the term J2EE.

This commit includes the following changes:

 * replace J2EE with Java EE where appropriate

This is not a blind search and replace. The following occurrences
remain unchanged:

 * references to old J2EE releases, most notably 1.3 and 1.4.
 * references to "Expert One-On-One J2EE Design and Development"
 * references to "Core J2EE patterns"
 * XML namespaces
 * package names

Issue: SPR-14811
See gh-1206
2016-10-15 11:49:00 +03:00
Philippe Marschall eee742da7f Remove OracleLobHandler from documentation
Now that OracleLobHandler has finally been removed it should also be
removed from the documentation.

This commit includes the following changes:

 * remove OracleLobHandler references from Javadoc
 * remove OracleLobHandler references from Asciidoctor

Issue: SPR-14809
Closes gh-1204
2016-10-14 18:00:26 +03:00
Juergen Hoeller ab0d523cc0 Polishing
(cherry picked from commit 1932a9d)
2016-08-17 21:54:40 +02:00
Juergen Hoeller 5ac7a32c8a Raise JDBC driver feature baseline to JDBC 4.0+
Issue: SPR-13826
2016-07-28 10:51:29 +02:00
Juergen Hoeller b9ab895743 Inferred generics for newSetFromMap arrangements
Issue: SPR-13188
2016-07-26 21:26:31 +02:00
Juergen Hoeller e03dea1d64 Polishing 2016-07-26 17:15:19 +02:00
Juergen Hoeller 610bdf1cc3 DataSource adapters expose setCatalog/setSchema next to setUsername/setPassword
Issue: SPR-14501
2016-07-21 14:06:40 +02:00
Juergen Hoeller 99be15f58b Revise encoding steps towards use of JDK Charset and StandardCharsets
Issue: SPR-14492
2016-07-19 23:43:06 +02:00
Juergen Hoeller d07381e862 Avoid deprecated number constructors on JDK 9
Issue: SPR-13344
2016-07-19 19:25:55 +02:00
Juergen Hoeller aaac199e8b Consistently use constructor-based instantiation instead of Class.newInstance / BeanUtils.instantiate
Issue: SPR-14486
2016-07-19 19:21:06 +02:00
Juergen Hoeller 7287baefeb GenericSqlQuery configured with RowMapper instance
Issue: SPR-14489
2016-07-19 18:44:06 +02:00
Juergen Hoeller dc1664939c Javadoc fixes and pruning of outdated references 2016-07-15 22:12:11 +02:00
Stephane Nicoll e4b0486c5a Add @FunctionalInterface on candidate interfaces
Issue: SPR-14432
2016-07-06 14:32:13 +02:00
Juergen Hoeller bc2c22d51e Streamline XML namespace support towards unversioned schemas
This commit also removes support code for outdated options which were only available in older schema versions.

Issue: SPR-13499
2016-07-05 20:50:03 +02:00
Sam Brannen 1391248ea6 Introduce log4j 2 for Spring's test suite
This commit adds a test runtime dependency on log4j 2 for every project
and migrates all log4j.properties files to log4j2-test.xml files.

Issue: SPR-14431
2016-07-05 19:19:09 +02:00
Stephane Nicoll 00d2606b00 Explicit type can be replaced by <>
Issue: SPR-13188
2016-07-05 17:00:34 +02:00
Juergen Hoeller 0fc0ce78ae Drop deprecated dependencies on Log4j, JRuby, JExcel, Burlap, Commons Pool/DBCP
This commit also removes outdated support classes for Oracle, GlassFish, JBoss.

Issue: SPR-14429
2016-07-05 15:46:53 +02:00
Juergen Hoeller 51252ebbca Avoid defensive checks against Java 8 API (java.util.Optional etc)
This commit also fixes broken javadoc links and code references.

Issue: SPR-13188
2016-07-05 02:09:00 +02:00
Juergen Hoeller d341624e91 Drop JDO support
Issue: SPR-14130
2016-07-04 23:34:48 +02:00
Juergen Hoeller 0900808820 Method-level @SuppressWarnings("unchecked") for generic varargs 2016-07-04 23:20:41 +02:00
Juergen Hoeller 7c96059ca3 BeanPropertyRowMapper uses ConversionService for date-time support
Issue: SPR-13888
2016-06-09 19:19:08 +02:00
Juergen Hoeller ca9ffa2012 Convenience constructors for CompositeDatabasePopulator
Issue: SPR-14313
2016-06-01 22:02:31 +02:00
Sanghyuk Jung 06e3ee6820 Polish javadoc in TableMetaDataContext
Closes gh-1065
2016-05-26 07:50:17 +02:00
Stephane Nicoll 7d4d3db0dd Add alternative database name for HANA
Issue: SPR-14261
2016-05-23 07:43:49 +02:00
Johnny Lim 44e652f99e Remove duplicate words
Closes gh-1039
2016-04-19 08:24:21 +02:00
Juergen Hoeller 74608e6b49 Polishing 2016-04-12 16:03:57 +02:00
Juergen Hoeller 537193a4e0 Consistent license header 2016-04-11 20:49:38 +02:00
Juergen Hoeller 6573e9142c Polishing 2016-04-05 12:17:21 +02:00
Juergen Hoeller 797f5dbba6 StatementCreatorUtils handles Types.BOOLEAN through PreparedStatement.setBoolean
Issue: SPR-14116
2016-04-05 11:12:36 +02:00
Juergen Hoeller 517ebd1d3e Consistent formatting 2016-03-24 19:22:50 +01:00
Juergen Hoeller 0b1639d963 JdbcTemplate passes negative values other than -1 on to the driver (for MySQL's special values)
Issue: SPR-14028
2016-03-11 14:59:00 +01:00
Cory Klein 71cf7b4053 Fix typo
Closes gh-992
2016-03-09 08:53:47 +01:00
Juergen Hoeller 923534595c ScriptUtils.executeSqlScript logs SQLWarnings at debug level
Issue: SPR-13959
2016-02-18 17:37:22 +01:00
Stephane Nicoll 714ae2684c Support for global separator in JDBC namespace
Previously, if a database needs to be initialized with several scripts
and many (or all) use a custom separator, said separator must be repeated
for each script.

This commit introduces a `separator` property at the parent element level
that can be used to customize the default separator. This is available
for both the `initialize-database` and `embedded-database` elements.

Issue: SPR-13792
2016-01-18 16:09:07 +01:00
Juergen Hoeller e48ec4fcd3 StatementCreatorUtils always tries getParameterType on Oracle 12c driver
Issue: SPR-13825
2015-12-29 11:19:21 +01:00
Sam Brannen 5b3edcd9f9 Spring Cleaning in December
- Delete unused imports
- Delete unused code
- Clean up warnings
2015-12-17 20:27:33 +01:00
Stephane Nicoll 752d3c715a Initiate structure for 4.3 XSDs 2015-12-17 15:43:23 +01:00
Juergen Hoeller 78dad4cfc3 Jdbc4SqlXmlHandler returns null as documented (instead of throwing NPE)
Issue: SPR-13782
2015-12-09 16:09:11 +01:00
Juergen Hoeller 11806b9215 Class identity comparisons wherever possible (and further polishing)
Issue: SPR-12926
2015-12-09 12:28:09 +01:00
Juergen Hoeller d2ad2c3af8 StatementCreatorUtils detects Microsoft SQL Server driver 4.0 as well
Issue: SPR-13772
2015-12-07 17:37:52 +01:00
Juergen Hoeller e8a0ef0206 Polishing 2015-11-12 00:48:14 +01:00
Juergen Hoeller cc06183668 SimpleJdbcCall reliably throws exception on missing stored procedure
Issue: SPR-13669
2015-11-12 00:47:46 +01:00
Juergen Hoeller cca037a74d Polishing 2015-11-02 14:42:46 +01:00
Juergen Hoeller 6685c78cea Avoid NPE for anonymous SqlParameter in CallMetaDataContext
Issue: SPR-13628
2015-11-02 14:27:33 +01:00
Juergen Hoeller 81342f14d4 Declared JDBC operation compiled flag as volatile
Issue: SPR-13617
2015-10-28 14:28:32 +01:00
Juergen Hoeller 11d1f050e9 NamedParameterUtils skips Postgres-style ?? operator
Issue: SPR-13582
2015-10-26 22:47:12 +01:00
Tobias Stoeckmann ed4197febb Fix typo
Closes gh-887
2015-10-11 16:55:41 +02:00
Sam Brannen d5ee787e1e Migrate JUnit 3 tests to JUnit 4
This commit migrates all remaining tests from JUnit 3 to JUnit 4, with
the exception of Spring's legacy JUnit 3.8 based testing framework that
is still in use in the spring-orm module.

Issue: SPR-13514
2015-09-27 21:17:51 +02:00
Juergen Hoeller b23c23279b AbstractEmbeddedDatabaseConfigurer explicitly closes JDBC Connection on shutdown
Issue: SPR-13474
2015-09-21 20:42:50 +02:00
Sam Brannen 8af0151f1b Suppress recent deprecation warnings in tests 2015-08-27 17:57:50 +02:00
Sam Brannen abc805819f Polish Javadoc for EmbeddedDatabaseBuilder 2015-08-27 17:27:53 +02:00
Juergen Hoeller 5e43f9b88f Deprecate Commons DBCP 1.x support along with Commons Pool 1.x
Issue: SPR-12532
2015-08-27 12:37:21 +02:00
Juergen Hoeller 5f3559fbad Call statement support for SAP HANA
Issue: SPR-13381
2015-08-25 17:54:38 +02:00
Juergen Hoeller 35e1eca9e8 BeanPropertyRowMapper logs in case of no corresponding property as well
Issue: SPR-13323
2015-08-25 17:54:26 +02:00
Sam Brannen a43d78ea55 Suppress warnings in tests in spring-jdbc 2015-08-21 23:56:01 +02:00
Sam Brannen 9ab4062317 Clean up warnings in tests in spring-jdbc 2015-08-19 23:29:57 +02:00
Sam Brannen d54aab2338 Log connection URL for embedded databases
Prior to this commit, EmbeddedDatabaseFactory logged the name of an
embedded database just before it was created; however, the name alone
is not sufficient for connecting to the database via external tools
such as the H2 Web Console.

This commit updates EmbeddedDatabaseFactory to make it easier to
connect to embedded databases via external tools by logging the
complete connection URL for an embedded database as it's being created.
In addition, EmbeddedDatabaseFactory now logs when an embedded database
is being shut down.

Issue: SPR-13370
2015-08-19 22:22:11 +02:00
Sam Brannen 2025d5c35e Polish Javadoc and log messages for embedded databases 2015-08-19 21:44:07 +02:00
Kazuki Shimizu 93919204a1 Add missing @since tag
Issue: SPR-12801
2015-08-15 09:07:37 +02:00
Juergen Hoeller e0f012f32d Removal of redundant JdkVersion checks in the test suite
Issue: SPR-13312
2015-08-12 18:42:36 +02:00
Juergen Hoeller bec3b0fa1a Deprecate JdkVersion (for optimistic compatibility with newer JDK generations)
Issue: SPR-13312
2015-08-12 16:14:43 +02:00
Juergen Hoeller edd6e76b9f Polishing 2015-07-21 22:58:34 +02:00
Juergen Hoeller 2934256257 Polishing 2015-07-15 00:08:11 +02:00
ndebeiss 629bcb6599 Support single quotes nested in double quotes in SQL scripts
Some databases such as Oracle permit double quoted column aliases that
contain case-sensitive characters, single quotes, and other special
characters; however, prior to this commit, SqlScripts interpreted a
single quote nested within double quotes as the start of a string
literal resulting in improper parsing.

This commit addresses this issue by ensuring that double quoted strings
such as column aliases are properly parsed even when containing single
quotes.

Issue: SPR-13218
2015-07-14 15:01:01 +03:00
Juergen Hoeller e0329306df JdbcTemplate's queryForObject allows for specifying primitive types as well
Issue: SPR-13220
2015-07-13 21:30:57 +02:00
Juergen Hoeller 41b58584ea BeanPropertyRowMapper uses US locale for lower-case conversion by default
Issue: SPR-13216
2015-07-13 14:59:43 +02:00
Sam Brannen 6c530b7bfb Delete trailing whitespace in XML files 2015-06-19 17:14:10 +02:00
Juergen Hoeller b4095c3e1d Class identity comparisons wherever possible
Issue: SPR-12926
2015-05-20 14:34:16 +02:00
Stephane Nicoll 8dec8823fb Allow parameter name binding for SimpleJdbcCall
Update SimpleJdbcCall to offer a way to use named parameters binding
instead of the simple `?` binding it offers thus far.

Issue: SPR-12801
2015-05-15 09:54:03 +02:00
Juergen Hoeller 00147379f9 Polishing
(cherry picked from commit 9e925aa)
2015-05-11 22:22:23 +02:00
Sam Brannen 4f8ef80342 Update doc for resultsMapCaseInsensitive flag in JdbcTemplate
Issue: SPR-12979
2015-05-05 14:43:32 +02:00
Juergen Hoeller cddcf3637d Polishing 2015-04-16 21:54:03 +02:00
Juergen Hoeller 050e581c10 StatementCreatorUtils.setValue only uses setString etc for Types.OTHER in case of Oracle
Issue: SPR-12890
2015-04-16 21:53:51 +02:00
Sam Brannen 1226596b8b Document connection handling in ScriptUtils
This commit improves the documentation for ScriptUtils by explicitly
mentioning that a JDBC Connection supplied to the one of the
executeSqlScript() methods will not be released automatically.

Issue: SPR-12908
2015-04-14 23:00:43 +02:00
Sam Brannen c0fbe0ae5a Support unique names for embedded databases
Development teams often encounter errors with embedded databases if
their test suite inadvertently attempts to recreate additional
instances of the same database. This can happen quite easily if an XML
configuration file or @Configuration class is responsible for creating
an embedded database and the corresponding configuration is then reused
across multiple testing scenarios within the same test suite (i.e.,
within the same JVM process) -- for example, integration tests against
embedded databases whose ApplicationContext configuration only differs
with regard to which bean definition profiles are active.

The root cause of such errors is the fact that Spring's
EmbeddedDatabaseFactory (used internally by both the
<jdbc:embedded-database> XML namespace element and the
EmbeddedDatabaseBuilder for Java Config) will set the name of the
embedded database to "testdb" if not otherwise specified. For the case
of <jdbc:embedded-database>, the embedded database is typically
assigned a name equal to the bean's id. Thus, subsequent attempts to
create an embedded database will not result in a new database. Instead,
the same JDBC connection URL will be reused, and attempts to create a
new embedded database will actually point to an existing embedded
database created from the same configuration.

This commit addresses this common issue by introducing support for
generating unique names for embedded databases. This support can be
enabled via:

 - EmbeddedDatabaseFactory.setGenerateUniqueDatabaseName()

 - EmbeddedDatabaseBuilder.generateUniqueName()

 - <jdbc:embedded-database generate-name="true" ... >

Issue: SPR-8849
2015-03-21 00:21:59 +01:00
Sam Brannen c36c6cbfaa Introduce database-name in <jdbc:embedded-database>
Prior to this commit, the EmbeddedDatabaseBeanDefinitionParser set the
name of the embedded database that it configured to the value of its
'id'. This made it impossible to assign unique names to embedded
databases if the same bean 'id' (e.g, 'dataSource') was used across
multiple application contexts loaded within the same JVM, which is
often the case within an integration test suite. In contrast, the
EmbeddedDatabaseBuilder already provides support for setting the name
in Java Config. Thus there is a disconnect between XML and Java
configuration.

This commit addresses this issue by introducing a 'database-name'
attribute in <jdbc:embedded-database />. This allows developers to set
unique names for embedded databases -- for example, via a SpEL
expression or a property placeholder that is influenced by the current
active bean definition profiles.

Issue: SPR-12835
2015-03-20 16:42:04 +01:00
Sam Brannen 7e2f12cf9f Allow <jdbc:embedded-database> to be declared w/o id
This commit modifies EmbeddedDatabaseBeanDefinitionParser so that the
<jdbc:embedded-database> XML namespace element can be declared as an
anonymous bean (i.e., without an explicit ID).

Issue: SPR-12834
2015-03-20 15:48:04 +01:00
Sam Brannen 85e4b24abb Introduce spring-jdbc-4.2.xsd
This commit introduces spring-jdbc-4.2.xsd in order to support upcoming
changes to the JDBC XML namespace.

In addition, this commit polishes the XSD documentation with regard to
use cases for script execution.
2015-03-20 15:31:41 +01:00
Juergen Hoeller bc6a98c144 Polishing (in particular updating javadoc references to Apache Commons) 2015-03-13 18:19:10 +01:00
Sam Brannen 23d52d5e35 Polish Javadoc for ScriptStatementFailedException constructor
Issue: SPR-12752
2015-02-28 00:12:53 +01:00
Juergen Hoeller 540d8792fe Fixed javadoc warnings and revised FastByteArrayOutputStream code style 2015-02-27 23:49:55 +01:00
Sam Brannen 45a80fa3ed Polish Javadoc for ScriptStatementFailedException.buildErrorMessage()
Issue: SPR-12752
2015-02-27 23:17:32 +01:00
Juergen Hoeller 2b3409461f Polishing 2015-02-27 22:29:42 +01:00
Sam Brannen 448c99f224 Introduce buildErrorMessage() utility in ScriptStatementFailedException
To eliminate code duplication, ScriptStatementFailedException and
ScriptUtils now delegate to a new buildErrorMessage() utility method.

Issue: SPR-12752
2015-02-27 21:41:52 +01:00
Sam Brannen 291b3de72b Refer to statement numbers in ScriptStatementFailedException
ScriptStatementFailedException now properly refers to statement numbers
instead of line numbers.

Issue: SPR-12752
2015-02-27 19:30:56 +01:00
Juergen Hoeller 8f228d1db4 ScriptUtils properly refers to statement numbers instead of line numbers
Issue: SPR-12752
2015-02-25 18:28:23 +01:00
Juergen Hoeller 9ac02b319d Remove pre-3.2 deprecated classes and methods
Issue: SPR-12578
2014-12-30 20:05:15 +01:00
Juergen Hoeller d6b16ffee3 Remove deprecated SimpleJdbcTemplate and supporting classes
Issue: SPR-11895
2014-12-30 14:59:38 +01:00
Juergen Hoeller 3b1584904f Polishing
Issue: SPR-12476
2014-11-27 19:57:53 +01:00
Juergen Hoeller fc92c0010e Revised SqlRowSet javadoc and support for JDBC 4.x ResultSet additions
Issue: SPR-12476
Issue: SPR-12480
2014-11-27 19:07:01 +01:00
Juergen Hoeller 2b4004d176 Consistent Map<String, ?> declarations and use of LinkedHashMap for incoming JDBC operation parameters
Issue: SPR-12462
2014-11-24 13:59:09 +01:00
Juergen Hoeller c0747a006a JdbcUtils.getResultSetValue avoids re-retrieval from ResultSet for Blob/Clob content (for Derby compatibility)
Issue: SPR-8810
2014-10-28 16:19:16 +01:00
Juergen Hoeller 1ad7a03357 Polishing 2014-10-21 18:49:03 +02:00
Juergen Hoeller 8325b10080 Consistent formatting of license headers, package javadocs, and import declarations 2014-10-21 01:44:07 +02:00
Juergen Hoeller 57d63a1903 JdbcTemplate and JmsTemplate pass settings with 0 values on to the driver
Issue: SPR-12338
2014-10-17 19:54:30 +02:00
Juergen Hoeller 43597bfed4 Polishing 2014-10-16 17:26:10 +02:00
Juergen Hoeller fb92934a7b Extracted AbstractIdentityColumnMaxValueIncrementer and introduced deleteSpecificValues mode
Issue: SPR-12327
2014-10-16 17:25:40 +02:00
Juergen Hoeller fd69ee541e DataSourceTransactionManager resets ConnectionHolder on doBegin failure
Issue: SPR-12280
2014-10-02 14:33:21 +02:00
unpush 31391232f4 fix typo 2014-10-02 10:45:47 +02:00
Stephane Nicoll b2d67914a8 Fix javadoc glitch
Issue: SPR-12282
2014-10-01 16:48:38 +02:00
Juergen Hoeller 3908804486 StatementCreatorUtils uses setClob/setNClob with stream argument in case of typed String value exceeding 4000 characters (for Oracle compatibility)
Issue: SPR-12240
2014-09-27 00:40:35 +02:00
Juergen Hoeller 3046fdd56a DefaultLobCreator's streamAsLob mode supports JDBC 4.0 setBlob/Clob variants without length parameter as well
Issue: SPR-12265
2014-09-27 00:16:01 +02:00
Juergen Hoeller d65db65fad DefaultLobCreator supports JDBC 4.0 set-stream variants without length parameter
Issue: SPR-12265
2014-09-26 23:56:43 +02:00
Juergen Hoeller 62340d6ccf Only release rolled-back database savepoints during managed nested transaction
Issue: SPR-12228
2014-09-22 17:29:10 +02:00
Juergen Hoeller 9c8f7d9246 Explicitly release rolled-back database savepoints during (long-running) transaction
Issue: SPR-12228
2014-09-22 14:59:04 +02:00
Sam Brannen f27c7df004 Avoid Gradle compiler warnings 2014-09-21 21:23:54 +02:00
Juergen Hoeller 8922da3af6 Generalized workaround for JDBC 4.1 getObject(index, requiredType) failures on MySQL and Derby
Issue: SPR-12174
Issue: SPR-12157
2014-09-12 16:27:48 +02:00
Juergen Hoeller 1e7bfd91a7 Polishing 2014-09-10 01:28:54 +02:00
Juergen Hoeller dedb04bd5c Workaround for Derby's limited support for JDBC 4.1 getObject(index, requiredType)
Issue: SPR-12157
2014-09-07 22:43:09 +02:00
Sam Brannen 79c75df088 Updated copyright date range 2014-08-20 23:53:25 +02:00
Sam Brannen b5216c5165 Merge pull request #624 from leizhiyuan/master
Stop using deprecated JdbcTemplate.queryFor*() methods
2014-08-20 23:48:17 +02:00
Juergen Hoeller 759f430ba5 StatementCreatorUtils avoids direct calls with SQL type argument in case of Types.OTHER
Issue: SPR-8571
2014-08-19 20:52:54 +02:00
leizhiyuan 3fcdae8ae8 Clean Up Deprecated Method Call
change all testcases in spring-jdbc those use queryForInt and
queryForLong methods to queryForObject
2014-08-17 08:17:46 +08:00
Juergen Hoeller 4db258b9e3 Polishing 2014-08-11 22:32:03 +02:00
Juergen Hoeller ad475ffadf Consistent vararg declarations for String array setters 2014-08-08 17:17:09 +02:00
Juergen Hoeller 8f484d382e Polishing 2014-07-29 11:42:37 +02:00
Stephane Nicoll dd2bf28a4f Add missing XSDs
Commit b676c41805 should have added the 4.1 XSDs for the jdbc and oxm
modules.

Issue: SPR-12011
2014-07-19 18:42:05 +02:00
Juergen Hoeller 9d6c38bd54 Consistent bracket alignment 2014-07-18 17:21:58 +02:00
Juergen Hoeller 55c351523d Polishing 2014-07-07 16:28:48 +02:00
Juergen Hoeller 4082274630 SQLStateSQLExceptionTranslator checks exception class name for timeout indication before resorting to UncategorizedSQLException
Issue: SPR-11959
2014-07-07 16:26:25 +02:00
Juergen Hoeller ec4e6e0b0e StatementCreatorUtils populates NVARCHAR, LONGNVARCHAR, NCLOB via setString as well
Issue: SPR-11938
2014-07-01 20:30:23 +02:00
Juergen Hoeller 0451232eb4 Polishing
(cherry picked from commit 86ea305)
2014-07-01 15:14:31 +02:00
Juergen Hoeller a6f3f101e4 Preparations for eventual removal of ParameterizedRowMapper along with SimpleJdbcTemplate
Issue: SPR-11895
2014-06-24 19:26:53 +02:00
Juergen Hoeller 18131bf611 Consistent declaration of private static final logger variables
Issue: SPR-11905
2014-06-24 14:02:05 +02:00
Sam Brannen f442ce180e Polish assertions and Javadoc for ResourceDatabasePopulator 2014-06-07 14:13:45 +02:00
Sam Brannen 5fd6ebb548 Introduce annotation to execute SQL scripts in the TCF
Prior to this commit, it was possible to execute SQL scripts
programmatically via ResourceDatabasePopulator, JdbcTestUtils, and
ScriptUtils. Furthermore, it was also possible to execute SQL scripts
declaratively via the <jdbc> XML namespace. However, it was not
possible to execute SQL scripts declaratively on a per test class or
per test method basis.

This commit makes it possible to declaratively configure SQL scripts
for execution in integration tests via annotations that can be declared
at the class or method level. Details follow.

 - Introduced a repeatable @DatabaseInitializer annotation that can be
   used to configure SQL scripts at the class or method level with
   method-level overrides. @DatabaseInitializers serves as a container
   for @DatabaseInitializer.

 - Introduced a new DatabaseInitializerTestExecutionListener that is
   responsible for parsing @DatabaseInitializer and
   @DatabaseInitializers and executing SQL scripts.

 - DatabaseInitializerTestExecutionListener is registered by default in
   abstract base test classes as well as in TestContextBootstrapper
   implementations.

 - @DatabaseInitializer and @DatabaseInitializers may be used as
   meta-annotations; however, attribute overrides are not currently
   supported for repeatable annotations used as meta-annotations. This
   is a known limitation of Spring's AnnotationUtils.

 - The semantics for locating SQL script resources is consistent with
   @ContextConfiguration's semantics for locating XML configuration
   files. In addition, a default SQL script can be detected based
   either on the name of the annotated class or on the name of the
   annotated test method.

 - @DatabaseInitializer allows for specifying which DataSource and
   PlatformTransactionManager to use from the test's
   ApplicationContext, including default conventions consistent with
   TransactionalTestExecutionListener and @TransactionConfiguration.

 - @DatabaseInitializer supports all of the script configuration options
   currently supported by ResourceDatabasePopulator.

 - @DatabaseInitializer and DatabaseInitializerTestExecutionListener
   support execution phases for scripts that dictate when SQL scripts
   are executed (i.e., before or after a test method).

 - SQL scripts can be executed within the current test's transaction if
   present, outside of the current test's transaction if present, or
   always in a new transaction, depending on the value of the boolean
   requireNewTransaction flag in @DatabaseInitializer.

 - DatabaseInitializerTestExecutionListener delegates to
   ResourceDatabasePopulator#execute to actually execute the scripts.

Issue: SPR-7655
2014-06-05 20:06:11 +02:00
Juergen Hoeller f7b465390c Moved @Uses annotations to org.springframework.lang; fixed Base64Utils to declare Java 8, and fixed PathResource's declaration to refer to Java 7.
Issue: SPR-11604
2014-06-04 21:34:23 +02:00
Stephane Nicoll 8614df8bd4 Add error code for SAP Hana
This commit adds a SQLErrorCodes instance for SAP DB, based on a
contribution from Andrew Clemons

Mostly based on SAP Hana SPS 07 with a few additional codes that are
only present is previous versions:

* -813 - Cannot connect to host somehost:30115 [Connection refused]
* -709 - Unknown host somehost:30115 [somehost], -709.]
* -708 - Cannot connect to jdbc:sap://somehost:30115 [Receive of connect failed.]
* -11210 - Invalid column index XYZ.

Issue: SPR-11770
2014-05-15 17:36:55 +02:00
Juergen Hoeller 0728e32e7f ResultSetWrappingSqlRowSet preserves first matching column per name (as defined in ResultSet's javadoc)
Issue: SPR-11786
2014-05-15 14:27:44 +02:00
Stephane Nicoll bd85c916eb Integrate animal sniffer
Animal sniffer provides tools to assist verifying that classes
compiled with a newer JDK are compatible with an older JDK.

This integratesthe latest version of the tool (1.11) that
permits the use of custom annotations. Added @UsesJava7,
@UsesJava8 and @UsesSunHttpServer and annotated the few places
where we rely on a specific environment.

The verification process can be invoked by running the 'sniff'
task.

Issue: SPR-11604

polishing
2014-04-30 13:51:01 +02:00
Juergen Hoeller 02aca9c754 Polishing 2014-04-30 00:01:07 +02:00
Juergen Hoeller 6cb45f714e General defensiveness about the bootstrap ClassLoader (i.e. null ClassLoader)
Issue: SPR-11721
(cherry picked from commit 59cef3c)
2014-04-28 00:47:21 +02:00
Philippe Marschall 7a7be598c2 Clean up spring-jdbc tests warnings
Clean up compiler warnings in the tests of spring-jdbc. This commit
adds type parameters to all the types (mostly `List` and `Map`). In
addition it uses Java 5 autoboxing to get rid of all of the following

 * new Integer
 * new Long
 * new Float
 * new Double
 * new Boolean
 * new String

This should be unnoticeably faster since interning can be uses for
Integer and such.

After this commit the only warnings in spring-jdbc left are:

* raw type warning in `MapDataSourceLookupTests`, that code would never
  compile with generics
* deprecation warning for `#queryForInt` and `#queryForLong`
2014-04-22 07:18:04 +02:00
Sam Brannen 09248a0b37 Polish ResourceDatabasePopulatorTests 2014-04-14 10:54:33 +02:00
Sam Brannen b4995f7e4f Add script after setting scripts in RsrcDbPopultr
Prior to this commit it was impossible to add additional scripts to a
ResourceDatabasePopulator after setScripts() had been invoked.

This commit fixes this by ensuring that the internal scripts list
continues to be modifiable when setScripts() is invoked.

Issue: SPR-11691
2014-04-13 15:06:47 +02:00
Sam Brannen 84f678a06b Assert preconditions in ResourceDatabasePopulator
Prior to this commit ResourceDatabasePopulator did not assert any
preconditions for constructor and method arguments. Consequently,
errors would not be encountered until the populator was executed.

This commit addresses this issue by ensuring that preconditions for
constructor and method arguments are asserted immediately, throwing
IllegalArgumentExceptions where appropriate.

Issue: SPR-11690
2014-04-13 14:51:42 +02:00
Sam Brannen 8fecee8c8a Improve Javadoc in SQL script support classes 2014-04-13 12:31:07 +02:00
Sam Brannen 910dd41467 Polish AbstractDatabasePopulatorTests 2014-04-11 18:43:36 +02:00
Sam Brannen 1753f5d1ca 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
2014-04-11 18:19:21 +02:00
Sam Brannen cc0ae3a881 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
2014-04-11 17:44:27 +02:00
Juergen Hoeller 3fef35879d JDBC 3.0 related javadoc overhaul
Issue: SPR-11600
2014-04-10 15:52:26 +02:00
Juergen Hoeller 37679384e8 JdbcUtils uses JDBC 4.1 getObject(int, Class) for unknown ResultSet value types
Comes with general JDBC 3.0+ baseline upgrade, removing defensive measures.

Issue: SPR-11600
2014-04-10 15:51:44 +02:00
Sam Brannen 5d049e0de8 Introduce execute(DataSource) in ResrcDbPopulator
To simplify common use cases, this commit introduces a new
execute(DataSource) method in ResourceDatabasePopulator that complements
the existing populate(Connection) method.

Issue: SPR-11629
2014-03-30 17:01:48 +02:00
Sam Brannen b766686c40 Remove duplicate @since tags in EmbeddedDatabaseBuilder 2014-03-30 16:08:44 +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