Remove KClass based Kotlin extensions
Issue: SPR-15660
This commit is contained in:
@@ -17,17 +17,8 @@
|
||||
package org.springframework.jdbc.core
|
||||
|
||||
import java.sql.ResultSet
|
||||
import kotlin.reflect.KClass
|
||||
|
||||
|
||||
/**
|
||||
* Extension for [JdbcOperations.queryForObject] providing a [KClass] based variant
|
||||
*
|
||||
* @author Mario Arias
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> JdbcOperations.queryForObject(sql: String, elementType: KClass<T>): T? = queryForObject(sql, elementType.java)
|
||||
|
||||
/**
|
||||
* Extension for [JdbcOperations.queryForObject] providing a `queryForObject<Foo>("...")` variant
|
||||
*
|
||||
@@ -45,15 +36,6 @@ inline fun <reified T : Any> JdbcOperations.queryForObject(sql: String): T? = qu
|
||||
fun <T : Any> JdbcOperations.queryForObject(sql: String, vararg args: Any, function: (ResultSet, Int) -> T): T =
|
||||
queryForObject(sql, RowMapper { resultSet, i -> function(resultSet, i) }, *args)
|
||||
|
||||
/**
|
||||
* Extension for [JdbcOperations.queryForObject] providing a [KClass] based variant
|
||||
*
|
||||
* @author Mario Arias
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> JdbcOperations.queryForObject(sql: String, args: Array<out Any>, argTypes: IntArray, requiredType: KClass<T>): T? =
|
||||
queryForObject(sql, args, argTypes, requiredType.java)
|
||||
|
||||
/**
|
||||
* Extension for [JdbcOperations.queryForObject] providing a `queryForObject<Foo>("...", arrayOf(arg1, argN), intArray(type1, typeN))` variant
|
||||
*
|
||||
@@ -63,15 +45,6 @@ fun <T : Any> JdbcOperations.queryForObject(sql: String, args: Array<out Any>, a
|
||||
inline fun <reified T : Any> JdbcOperations.queryForObject(sql: String, args: Array<out Any>, argTypes: IntArray): T? =
|
||||
queryForObject(sql, args, argTypes, T::class.java)
|
||||
|
||||
/**
|
||||
* Extension for [JdbcOperations.queryForObject] providing a [KClass] based variant
|
||||
*
|
||||
* @author Mario Arias
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> JdbcOperations.queryForObject(sql: String, args: Array<out Any>, requiredType: KClass<T>): T? =
|
||||
queryForObject(sql, args, requiredType.java)
|
||||
|
||||
/**
|
||||
* Extension for [JdbcOperations.queryForObject] providing a `queryForObject<Foo>("...", arrayOf(arg1, argN))` variant
|
||||
*
|
||||
@@ -81,15 +54,6 @@ fun <T : Any> JdbcOperations.queryForObject(sql: String, args: Array<out Any>, r
|
||||
inline fun <reified T : Any> JdbcOperations.queryForObject(sql: String, args: Array<out Any>): T? =
|
||||
queryForObject(sql, args, T::class.java)
|
||||
|
||||
/**
|
||||
* Extension for [JdbcOperations.queryForObject] providing a [KClass] based variant
|
||||
*
|
||||
* @author Mario Arias
|
||||
* @since 5.0
|
||||
*/
|
||||
fun <T : Any> JdbcOperations.queryForObject(sql: String, requiredType: KClass<T>, vararg args: Any): T? =
|
||||
queryForObject(sql, requiredType.java, *args)
|
||||
|
||||
|
||||
/**
|
||||
* Extension for [JdbcOperations.queryForList] providing a `queryForList<Foo>("...")` variant.
|
||||
|
||||
@@ -38,14 +38,6 @@ class JdbcOperationsExtensionsTests {
|
||||
@Mock(answer = Answers.RETURNS_MOCKS)
|
||||
lateinit var template: JdbcTemplate
|
||||
|
||||
@Test
|
||||
fun `queryForObject with KClass`() {
|
||||
val sql = "select age from customer where id = 3"
|
||||
val requiredType = Int::class
|
||||
template.queryForObject(sql, requiredType)
|
||||
verify(template, times(1)).queryForObject(sql, requiredType)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `queryForObject with reified type parameters`() {
|
||||
val sql = "select age from customer where id = 3"
|
||||
@@ -60,16 +52,6 @@ class JdbcOperationsExtensionsTests {
|
||||
verify(template, times(1)).queryForObject(eq(sql), any<RowMapper<Int>>(), eq(3))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `queryForObject with argTypes`() {
|
||||
val sql = "select age from customer where id = ?"
|
||||
val args = arrayOf(3)
|
||||
val argTypes = intArrayOf(JDBCType.INTEGER.vendorTypeNumber)
|
||||
val requiredType = Int::class
|
||||
template.queryForObject(sql, args, argTypes, requiredType)
|
||||
verify(template, times(1)).queryForObject(sql, args, argTypes, requiredType)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `queryForObject with reified type parameters and argTypes`() {
|
||||
val sql = "select age from customer where id = ?"
|
||||
@@ -79,14 +61,6 @@ class JdbcOperationsExtensionsTests {
|
||||
verify(template, times(1)).queryForObject(sql, args, argTypes, Integer::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `queryForObject with args`() {
|
||||
val sql = "select age from customer where id = ?"
|
||||
val args = arrayOf(3)
|
||||
template.queryForObject(sql, args, Int::class)
|
||||
verify(template, times(1)).queryForObject(sql, args, Int::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `queryForObject with reified type parameters and args`() {
|
||||
val sql = "select age from customer where id = ?"
|
||||
@@ -95,13 +69,6 @@ class JdbcOperationsExtensionsTests {
|
||||
verify(template, times(1)).queryForObject(sql, args, Integer::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `queryForObject with varargs`() {
|
||||
val sql = "select age from customer where id = ?"
|
||||
template.queryForObject(sql, Int::class, 3)
|
||||
verify(template, times(1)).queryForObject(sql, Int::class.java, 3)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `queryForList with reified type parameters`() {
|
||||
val sql = "select age from customer where id = 3"
|
||||
|
||||
Reference in New Issue
Block a user