spring-projects / spring-framework

Spring Framework
https://spring.io/projects/spring-framework
Apache License 2.0
56.67k stars 38.15k forks source link

Deprecate SimpleJdbcTestUtils in favor of JdbcTestUtils [SPR-9235] #13873

Closed spring-projects-issues closed 12 years ago

spring-projects-issues commented 12 years ago

Michel Zanini opened SPR-9235 and commented

Overview

Since SimpleJdbcTemplate is now deprecated, SimpleJdbcTestUtils should also be deprecated, and its methods could be moved to JdbcTestUtils, changing them to use JdbcTemplate instead.

Proposed Solution

The file attached is a patch where I did this. Also, I added two methods that are very useful for database testing:


Affects: 3.1.1

Attachments:

Sub-tasks:

Issue Links:

Referenced from: commits https://github.com/spring-projects/spring-framework/commit/d7fd70fa08704550bd46d359e96608e265925f8f, https://github.com/spring-projects/spring-framework/commit/a7d43773e870fc7bf4106d34f42e8f3c0337b7b7, https://github.com/spring-projects/spring-framework/commit/bd0c4b4d9974b4a54f4ebc79d1f419f46a1e5b2a

3 votes, 5 watchers

spring-projects-issues commented 12 years ago

Chris Beams commented

Added @thomas.risberg as a watcher. Thomas, this looks reasonable. If you see fit, please assign to yourself and schedule for an upcoming release.

spring-projects-issues commented 12 years ago

Ian Brandt commented

I'm looking forward to the release of this. I've used SimpleJdbcTestUtils extensively. As it stands upgrading from 3.0 to 3.1 implies a flood of deprecation warnings without an equivalent API to migrate to.

spring-projects-issues commented 12 years ago

Chris Beams commented

Ian, Michel, all,

This is an ideal candidate for a pull request - if anyone here is interested in contributing, you can start with Michel's original attachment here, and then follow the contributor guidelines to get it committed.

spring-projects-issues commented 12 years ago

Ian Brandt commented

Done: https://github.com/SpringSource/spring-framework/pull/90. Hopefully this is in time for a 3.1.2 backport.

spring-projects-issues commented 12 years ago

Michel Zanini commented

I added a comment on the Git pull request on Github. One SQL has an extra escape char (`) that should be removed.

spring-projects-issues commented 12 years ago

Ian Brandt commented

I just noticed 3.1.2 was released, and was sorry to see that this was not included. Is there going to be a 3.1.3? Is there anything I need to do to the above pull request to get it considered?

spring-projects-issues commented 12 years ago

Sam Brannen commented

This issue has been addressed in GitHub commit a7d43773e8 as described in the commit message:

Deprecate SimpleJdbcTestUtils in favor of JdbcTestUtils

Several static utility methods in SimpleJdbcTestUtils accept an instance of SimpleJdbcTemplate as an argument; however, SimpleJdbcTemplate has been deprecated since Spring 3.1 in favor of simply using JdbcTemplate which now also supports Java 5 language constructs such as var-args. Consequently, use of such methods from SimpleJdbcTestUtils results in deprecation warnings without an equivalent API to migrate to.

This commit addresses this issue by migrating all existing methods in SimpleJdbcTestUtils to JdbcTestUtils. The migrated methods now accept an instance of JdbcTemplate as an argument, thereby avoiding the deprecation warnings but maintaining semantic compatibility with the functionality previous available in SimpleJdbcTestUtils.

In addition, this commit also introduces two new methods:

  • countRowsInTableWhere(): counts the rows in a given table, using a provided WHERE clause
  • dropTables(): drops the tables with the specified names
spring-projects-issues commented 12 years ago

Sam Brannen commented

FYI: I have raised #14298 to have this feature considered for backporting to Spring 3.1.x.

So feel free to watch #14298 if you're interested.

spring-projects-issues commented 12 years ago

Ian Brandt commented

Thank you Sam!

spring-projects-issues commented 12 years ago

Sam Brannen commented

If you're following this issue, you may also be interested in #14299.