Closed spring-projects-issues closed 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.
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.
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.
Ian Brandt commented
Done: https://github.com/SpringSource/spring-framework/pull/90. Hopefully this is in time for a 3.1.2 backport.
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.
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?
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
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.
Ian Brandt commented
Thank you Sam!
Sam Brannen commented
If you're following this issue, you may also be interested in #14299.
Michel Zanini opened SPR-9235 and commented
Overview
Since
SimpleJdbcTemplate
is now deprecated,SimpleJdbcTestUtils
should also be deprecated, and its methods could be moved toJdbcTestUtils
, changing them to useJdbcTemplate
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:
dropTables()
: this method is similar todeleteFromTables()
but instead of removing all rows, it will drop the tables.countRowsInTable()
:countRowsInTable()
already exists, but I added this overloaded method that takes awhereClause
to augment the query.Affects: 3.1.1
Attachments:
Sub-tasks:
14298 Backport "Deprecate SimpleJdbcTestUtils in favor of JdbcTestUtils"
Issue Links:
14299 Introduce countRowsInTableWhere() and dropTables() in abstract transactional base classes in the TestContext framework ("is depended on by")
13630 Provide JdbcTemplate in abstract transactional base classes in the TestContext framework ("is depended on by")
14227 JdbcTestUtils should not interpret comments as a separate statement
13983 Reference Guide still recommends SimpleJdbcTemplate, which is now deprecated
11587 Deprecate SimpleJdbcTemplate in favor of JdbcTemplate
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