-
Notifications
You must be signed in to change notification settings - Fork 689
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Replace use of ResultSet in IColumnType.readObject() with common Resu…
…ltApi - Introduce ResultApi interface that wraps actual database result - Introduce JdbcResult and R2dbcResult - Since only getting object by index and/or type is supported by R2DBC, all uses of ResultSet specific getType() functions in source code have been replaced by getObject()
- Loading branch information
Showing
14 changed files
with
115 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/statements/api/ResultApi.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package org.jetbrains.exposed.sql.statements.api | ||
|
||
import java.sql.ResultSet | ||
|
||
/** Base class for wrapping data generated by executing a statement that queries the database. */ | ||
interface ResultApi { | ||
/** The actual data object returned by the database after statement execution. */ | ||
val result: Any | ||
|
||
/** | ||
* Returns the value of the column, at the specified [index], from the [result] object. | ||
* using the database's default type mapping. | ||
*/ | ||
fun getObject(index: Int): Any? | ||
|
||
/** | ||
* Returns the value of the column, at the specified [index], from the [result] object, | ||
* converted from the column SQL type to the specified data [type]. | ||
*/ | ||
fun <T> getObject(index: Int, type: Class<T>): T? | ||
} | ||
|
||
/** Class for wrapping a [java.sql.ResultSet] generated by executing a statement that queries a JDBC database. */ | ||
class JdbcResult( | ||
/** The actual [ResultSet] returned by the database after statement execution. */ | ||
override val result: ResultSet | ||
) : ResultApi { | ||
override fun getObject(index: Int): Any? = result.getObject(index) | ||
|
||
override fun <T> getObject(index: Int, type: Class<T>): T? = result.getObject(index, type) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.