Extract Reified method to Extension
Add update method
This commit is contained in:
@@ -44,7 +44,7 @@ class Connection(
|
||||
}
|
||||
|
||||
fun disconnect() {
|
||||
connection?.run { disconnect() }
|
||||
connection?.disconnect()
|
||||
}
|
||||
|
||||
fun <A> inTransaction(f: (Connection) -> CompletableFuture<A>) = connect().inTransaction(f)
|
||||
@@ -97,7 +97,7 @@ class Connection(
|
||||
values: List<Any?>,
|
||||
block: (QueryResult, List<R>) -> Unit
|
||||
): List<R> {
|
||||
val result = exec(sql, compileArgs(values))
|
||||
val result = exec(sql, values)
|
||||
val json = result.rows[0].getString(0)
|
||||
return if (json === null) {
|
||||
listOf<EntityI>() as List<R>
|
||||
|
||||
@@ -10,8 +10,19 @@ sealed interface EmbedExecutable {
|
||||
val name: String
|
||||
|
||||
/* Select One */
|
||||
|
||||
/**
|
||||
* Select One entity with list of parameters
|
||||
* Update [EntityI] with one entity as argument
|
||||
*/
|
||||
fun <R : EntityI> update(
|
||||
typeReference: TypeReference<R>,
|
||||
value: R,
|
||||
block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(typeReference, listOf(value), block)
|
||||
|
||||
/**
|
||||
* Select One [EntityI] with [List] of parameters
|
||||
*/
|
||||
fun <R : EntityI> selectOne(
|
||||
typeReference: TypeReference<R>,
|
||||
@@ -19,26 +30,60 @@ sealed interface EmbedExecutable {
|
||||
block: SelectOneCallback<R> = {}
|
||||
): R?
|
||||
|
||||
/**
|
||||
* Select One [EntityI] with [Map] of parameters
|
||||
*/
|
||||
fun <R : EntityI> selectOne(
|
||||
typeReference: TypeReference<R>,
|
||||
values: Map<String, Any?>,
|
||||
block: SelectOneCallback<R> = {}
|
||||
): R?
|
||||
|
||||
/**
|
||||
* Select One [EntityI] with multiple [Pair] of parameters
|
||||
*/
|
||||
fun <R : EntityI> selectOne(
|
||||
typeReference: TypeReference<R>,
|
||||
vararg values: Pair<String, Any?>,
|
||||
block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(typeReference, values.toMap(), block)
|
||||
|
||||
/* Select Multiples */
|
||||
|
||||
/**
|
||||
* Select Multiple [EntityI] with [List] of parameters
|
||||
*/
|
||||
fun <R : EntityI> select(
|
||||
typeReference: TypeReference<List<R>>,
|
||||
values: List<Any?> = emptyList(),
|
||||
block: SelectCallback<R> = {}
|
||||
): List<R>
|
||||
|
||||
/**
|
||||
* Select Multiple [EntityI] with [Map] of parameters
|
||||
*/
|
||||
fun <R : EntityI> select(
|
||||
typeReference: TypeReference<List<R>>,
|
||||
values: Map<String, Any?>,
|
||||
block: SelectCallback<R> = {}
|
||||
): List<R>
|
||||
|
||||
/**
|
||||
* Select Multiple [EntityI] with multiple [Pair] of parameters
|
||||
*/
|
||||
fun <R : EntityI> select(
|
||||
typeReference: TypeReference<List<R>>,
|
||||
vararg values: Pair<String, Any?>,
|
||||
block: SelectCallback<R> = {}
|
||||
): List<R> =
|
||||
select(typeReference, values.toMap(), block)
|
||||
|
||||
/* Select Paginated */
|
||||
|
||||
/**
|
||||
* Select Paginated [EntityI] with [Map] of parameters
|
||||
*/
|
||||
fun <R : EntityI> select(
|
||||
page: Int,
|
||||
limit: Int,
|
||||
@@ -47,6 +92,18 @@ sealed interface EmbedExecutable {
|
||||
block: SelectPaginatedCallback<R> = {}
|
||||
): Paginated<R>
|
||||
|
||||
/**
|
||||
* Select Paginated [EntityI] with multiple [Pair] of parameters
|
||||
*/
|
||||
fun <R : EntityI> select(
|
||||
page: Int,
|
||||
limit: Int,
|
||||
typeReference: TypeReference<List<R>>,
|
||||
vararg values: Pair<String, Any?>,
|
||||
block: SelectPaginatedCallback<R> = {}
|
||||
): Paginated<R> =
|
||||
select(page, limit, typeReference, values.toMap(), block)
|
||||
|
||||
fun exec(values: List<Any?> = emptyList()): QueryResult
|
||||
fun exec(values: Map<String, Any?>): QueryResult
|
||||
fun exec(vararg values: Pair<String, Any?>): QueryResult = exec(values.toMap())
|
||||
@@ -57,6 +114,5 @@ sealed interface EmbedExecutable {
|
||||
|
||||
fun sendQuery(values: List<Any?> = emptyList()): Int
|
||||
fun sendQuery(values: Map<String, Any?>): Int
|
||||
fun sendQuery(vararg values: Pair<String, Any?>): Int =
|
||||
sendQuery(values.toMap())
|
||||
fun sendQuery(vararg values: Pair<String, Any?>): Int = sendQuery(values.toMap())
|
||||
}
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
package fr.postgresjson.connexion
|
||||
|
||||
import com.fasterxml.jackson.core.type.TypeReference
|
||||
import fr.postgresjson.entity.EntityI
|
||||
|
||||
/* Select One */
|
||||
|
||||
inline fun <reified R : EntityI> EmbedExecutable.update(
|
||||
value: R,
|
||||
noinline block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
update(object : TypeReference<R>() {}, value, block)
|
||||
|
||||
inline fun <reified R : EntityI> EmbedExecutable.selectOne(
|
||||
values: List<Any?> = emptyList(),
|
||||
noinline block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(object : TypeReference<R>() {}, values, block)
|
||||
|
||||
inline fun <reified R : EntityI> EmbedExecutable.selectOne(
|
||||
values: Map<String, Any?>,
|
||||
noinline block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(object : TypeReference<R>() {}, values, block)
|
||||
|
||||
inline fun <reified R : EntityI> EmbedExecutable.selectOne(
|
||||
vararg values: Pair<String, Any?>,
|
||||
noinline block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(object : TypeReference<R>() {}, values = values, block)
|
||||
|
||||
/* Select Multiples */
|
||||
|
||||
inline fun <reified R : EntityI> EmbedExecutable.select(
|
||||
values: List<Any?> = emptyList(),
|
||||
noinline block: SelectCallback<R> = {}
|
||||
): List<R> =
|
||||
select(object : TypeReference<List<R>>() {}, values, block)
|
||||
|
||||
inline fun <reified R : EntityI> EmbedExecutable.select(
|
||||
values: Map<String, Any?>,
|
||||
noinline block: SelectCallback<R> = {}
|
||||
): List<R> =
|
||||
select(object : TypeReference<List<R>>() {}, values, block)
|
||||
|
||||
inline fun <reified R : EntityI> EmbedExecutable.select(
|
||||
vararg values: Pair<String, Any?>,
|
||||
noinline block: SelectCallback<R> = {}
|
||||
): List<R> =
|
||||
select(object : TypeReference<List<R>>() {}, values = values, block)
|
||||
|
||||
/* Select Paginated */
|
||||
|
||||
inline fun <reified R : EntityI> EmbedExecutable.select(
|
||||
page: Int,
|
||||
limit: Int,
|
||||
values: Map<String, Any?> = emptyMap(),
|
||||
noinline block: SelectPaginatedCallback<R> = {}
|
||||
): Paginated<R> =
|
||||
select(page, limit, object : TypeReference<List<R>>() {}, values, block)
|
||||
|
||||
inline fun <reified R : EntityI> EmbedExecutable.select(
|
||||
page: Int,
|
||||
limit: Int,
|
||||
vararg values: Pair<String, Any?>,
|
||||
noinline block: SelectPaginatedCallback<R> = {}
|
||||
): Paginated<R> =
|
||||
select(page, limit, object : TypeReference<List<R>>() {}, values = values, block)
|
||||
@@ -5,8 +5,23 @@ import com.github.jasync.sql.db.QueryResult
|
||||
import fr.postgresjson.entity.EntityI
|
||||
|
||||
interface Executable {
|
||||
|
||||
/* Select One */
|
||||
|
||||
/**
|
||||
* Update [EntityI] with one entity as argument
|
||||
*/
|
||||
fun <R : EntityI> update(
|
||||
sql: String,
|
||||
typeReference: TypeReference<R>,
|
||||
value: R,
|
||||
block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(sql, typeReference, listOf(value), block)
|
||||
|
||||
/**
|
||||
* Select One [EntityI] with [List] of parameters
|
||||
*/
|
||||
fun <R : EntityI> selectOne(
|
||||
sql: String,
|
||||
typeReference: TypeReference<R>,
|
||||
@@ -14,6 +29,9 @@ interface Executable {
|
||||
block: SelectOneCallback<R> = {}
|
||||
): R?
|
||||
|
||||
/**
|
||||
* Select One [EntityI] with [Map] of parameters
|
||||
*/
|
||||
fun <R : EntityI> selectOne(
|
||||
sql: String,
|
||||
typeReference: TypeReference<R>,
|
||||
@@ -21,8 +39,22 @@ interface Executable {
|
||||
block: SelectOneCallback<R> = {}
|
||||
): R?
|
||||
|
||||
/**
|
||||
* Select One [EntityI] with multiple [Pair] of parameters
|
||||
*/
|
||||
fun <R : EntityI> selectOne(
|
||||
sql: String,
|
||||
typeReference: TypeReference<R>,
|
||||
vararg values: Pair<String, Any?>,
|
||||
block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(sql, typeReference, values.toMap(), block)
|
||||
|
||||
/* Select Multiples */
|
||||
|
||||
/**
|
||||
* Select Multiple [EntityI] with [List] of parameters
|
||||
*/
|
||||
fun <R : EntityI> select(
|
||||
sql: String,
|
||||
typeReference: TypeReference<List<R>>,
|
||||
@@ -30,6 +62,9 @@ interface Executable {
|
||||
block: SelectCallback<R> = {}
|
||||
): List<R>
|
||||
|
||||
/**
|
||||
* Select Multiple [EntityI] with [Map] of parameters
|
||||
*/
|
||||
fun <R : EntityI> select(
|
||||
sql: String,
|
||||
typeReference: TypeReference<List<R>>,
|
||||
@@ -37,8 +72,22 @@ interface Executable {
|
||||
block: SelectCallback<R> = {}
|
||||
): List<R>
|
||||
|
||||
/**
|
||||
* Select Multiple [EntityI] with multiple [Pair] of parameters
|
||||
*/
|
||||
fun <R : EntityI> select(
|
||||
sql: String,
|
||||
typeReference: TypeReference<List<R>>,
|
||||
vararg values: Pair<String, Any?>,
|
||||
block: SelectCallback<R> = {}
|
||||
): List<R> =
|
||||
select(sql, typeReference, values.toMap(), block)
|
||||
|
||||
/* Select Paginated */
|
||||
|
||||
/**
|
||||
* Select Paginated [EntityI] with [Map] of parameters
|
||||
*/
|
||||
fun <R : EntityI> select(
|
||||
sql: String,
|
||||
page: Int,
|
||||
@@ -48,8 +97,31 @@ interface Executable {
|
||||
block: SelectPaginatedCallback<R> = {}
|
||||
): Paginated<R>
|
||||
|
||||
/**
|
||||
* Select Paginated [EntityI] with multiple [Pair] of parameters
|
||||
*/
|
||||
fun <R : EntityI> select(
|
||||
sql: String,
|
||||
page: Int,
|
||||
limit: Int,
|
||||
typeReference: TypeReference<List<R>>,
|
||||
vararg values: Pair<String, Any?>,
|
||||
block: SelectPaginatedCallback<R> = {}
|
||||
): Paginated<R> =
|
||||
select(sql, page, limit, typeReference, values.toMap(), block)
|
||||
|
||||
fun <R : EntityI> exec(sql: String, value: R): QueryResult = exec(sql, listOf(value))
|
||||
fun exec(sql: String, values: List<Any?> = emptyList()): QueryResult
|
||||
fun exec(sql: String, values: Map<String, Any?>): QueryResult
|
||||
fun exec(sql: String, vararg values: Pair<String, Any?>): QueryResult = exec(sql, values.toMap())
|
||||
|
||||
fun <R : EntityI> perform(sql: String, value: R) { perform(sql, listOf(value)) }
|
||||
fun perform(sql: String, values: List<Any?>) { exec(sql, values) }
|
||||
fun perform(sql: String, values: Map<String, Any?>) { exec(sql, values) }
|
||||
fun perform(sql: String, vararg values: Pair<String, Any?>) = perform(sql, values.toMap())
|
||||
|
||||
fun <R : EntityI> sendQuery(sql: String, value: R): Int = sendQuery(sql, listOf(value))
|
||||
fun sendQuery(sql: String, values: List<Any?> = emptyList()): Int
|
||||
fun sendQuery(sql: String, values: Map<String, Any?>): Int
|
||||
fun sendQuery(sql: String, vararg values: Pair<String, Any?>): Int = sendQuery(sql, values.toMap())
|
||||
}
|
||||
|
||||
@@ -12,112 +12,64 @@ class Function(val definition: Function, override val connection: Connection) :
|
||||
|
||||
override val name: String = definition.name
|
||||
|
||||
/**
|
||||
* Update [EntityI]
|
||||
*/
|
||||
override fun <R : EntityI> update(
|
||||
typeReference: TypeReference<R>,
|
||||
value: R,
|
||||
block: (QueryResult, R?) -> Unit
|
||||
): R? =
|
||||
connection.update(compileSql(value), typeReference, value, block)
|
||||
|
||||
/* Select One */
|
||||
|
||||
/**
|
||||
* Select One entity with list of parameters
|
||||
* Select One [EntityI] with [List] of parameters
|
||||
*/
|
||||
override fun <R : EntityI> selectOne(
|
||||
typeReference: TypeReference<R>,
|
||||
values: List<Any?>,
|
||||
block: (QueryResult, R?) -> Unit
|
||||
): R? {
|
||||
val args = compileArgs(values)
|
||||
val sql = "SELECT * FROM ${definition.name} ($args)"
|
||||
|
||||
return connection.selectOne(sql, typeReference, values, block)
|
||||
}
|
||||
|
||||
inline fun <reified R : EntityI> selectOne(
|
||||
values: List<Any?> = emptyList(),
|
||||
noinline block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(object : TypeReference<R>() {}, values, block)
|
||||
|
||||
inline fun <reified R : EntityI> selectOne(
|
||||
value: R,
|
||||
noinline block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(object : TypeReference<R>() {}, listOf(value), block)
|
||||
connection.selectOne(compileSql(values), typeReference, values, block)
|
||||
|
||||
/**
|
||||
* Select One entity with named parameters
|
||||
* Select One [EntityI] with named parameters
|
||||
*/
|
||||
override fun <R : EntityI> selectOne(
|
||||
typeReference: TypeReference<R>,
|
||||
values: Map<String, Any?>,
|
||||
block: (QueryResult, R?) -> Unit
|
||||
): R? {
|
||||
val args = compileArgs(values)
|
||||
val sql = "SELECT * FROM ${definition.name} ($args)"
|
||||
|
||||
return connection.selectOne(sql, typeReference, values, block)
|
||||
}
|
||||
|
||||
inline fun <reified R : EntityI> selectOne(
|
||||
values: Map<String, Any?>,
|
||||
noinline block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(object : TypeReference<R>() {}, values, block)
|
||||
|
||||
inline fun <reified R : EntityI> selectOne(
|
||||
vararg values: Pair<String, Any?>,
|
||||
noinline block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(values.toMap(), block)
|
||||
connection.selectOne(compileSql(values), typeReference, values, block)
|
||||
|
||||
/* Select Multiples */
|
||||
|
||||
/**
|
||||
* Select list of entities with list of parameters
|
||||
* Select multiple [EntityI] with [List] of parameters
|
||||
*/
|
||||
override fun <R : EntityI> select(
|
||||
typeReference: TypeReference<List<R>>,
|
||||
values: List<Any?>,
|
||||
block: (QueryResult, List<R>) -> Unit
|
||||
): List<R> {
|
||||
val args = compileArgs(values)
|
||||
val sql = "SELECT * FROM ${definition.name} ($args)"
|
||||
|
||||
return connection.select(sql, typeReference, values, block)
|
||||
}
|
||||
|
||||
inline fun <reified R : EntityI> select(
|
||||
values: List<Any?> = emptyList(),
|
||||
noinline block: SelectCallback<R> = {}
|
||||
): List<R> =
|
||||
select(object : TypeReference<List<R>>() {}, values, block)
|
||||
connection.select(compileSql(values), typeReference, values, block)
|
||||
|
||||
/**
|
||||
* Select list of entities with named parameters
|
||||
* Select multiple [EntityI] with named parameters
|
||||
*/
|
||||
override fun <R : EntityI> select(
|
||||
typeReference: TypeReference<List<R>>,
|
||||
values: Map<String, Any?>,
|
||||
block: (QueryResult, List<R>) -> Unit
|
||||
): List<R> {
|
||||
val args = compileArgs(values)
|
||||
val sql = "SELECT * FROM ${definition.name} ($args)"
|
||||
|
||||
return connection.select(sql, typeReference, values, block)
|
||||
}
|
||||
|
||||
inline fun <reified R : EntityI> select(
|
||||
values: Map<String, Any?>,
|
||||
noinline block: SelectCallback<R> = {}
|
||||
): List<R> =
|
||||
select(object : TypeReference<List<R>>() {}, values, block)
|
||||
|
||||
inline fun <reified R : EntityI> select(
|
||||
vararg values: Pair<String, Any?>,
|
||||
noinline block: SelectCallback<R> = {}
|
||||
): List<R> =
|
||||
select(values.toMap(), block)
|
||||
connection.select(compileSql(values), typeReference, values, block)
|
||||
|
||||
/* Select Paginated */
|
||||
|
||||
/**
|
||||
* Select Multiple with pagination
|
||||
* Select Multiple [EntityI] with pagination
|
||||
*/
|
||||
override fun <R : EntityI> select(
|
||||
page: Int,
|
||||
@@ -131,43 +83,14 @@ class Function(val definition: Function, override val connection: Connection) :
|
||||
.plus("offset" to offset)
|
||||
.plus("limit" to limit)
|
||||
|
||||
val args = compileArgs(newValues)
|
||||
val sql = "SELECT * FROM ${definition.name} ($args)"
|
||||
|
||||
return connection.select(sql, page, limit, typeReference, values, block)
|
||||
return connection.select(compileSql(newValues), page, limit, typeReference, values, block)
|
||||
}
|
||||
|
||||
inline fun <reified R : EntityI> select(
|
||||
page: Int,
|
||||
limit: Int,
|
||||
values: Map<String, Any?> = emptyMap(),
|
||||
noinline block: SelectPaginatedCallback<R> = {}
|
||||
): Paginated<R> =
|
||||
select(page, limit, object : TypeReference<List<R>>() {}, values, block)
|
||||
/* Execute function without treatments */
|
||||
|
||||
inline fun <reified R : EntityI> select(
|
||||
page: Int,
|
||||
limit: Int,
|
||||
vararg values: Pair<String, Any?>,
|
||||
noinline block: SelectPaginatedCallback<R> = {}
|
||||
): Paginated<R> =
|
||||
select(page, limit, object : TypeReference<List<R>>() {}, values.toMap(), block)
|
||||
override fun exec(values: List<Any?>): QueryResult = connection.exec(compileSql(values), values)
|
||||
|
||||
/* Execute function without traitements */
|
||||
|
||||
override fun exec(values: List<Any?>): QueryResult {
|
||||
val args = compileArgs(values)
|
||||
val sql = "SELECT * FROM ${definition.name} ($args)"
|
||||
|
||||
return connection.exec(sql, values)
|
||||
}
|
||||
|
||||
override fun exec(values: Map<String, Any?>): QueryResult {
|
||||
val args = compileArgs(values)
|
||||
val sql = "SELECT * FROM ${definition.name} ($args)"
|
||||
|
||||
return connection.exec(sql, values)
|
||||
}
|
||||
override fun exec(values: Map<String, Any?>): QueryResult = connection.exec(compileSql(values), values)
|
||||
|
||||
override fun sendQuery(values: List<Any?>): Int {
|
||||
exec(values)
|
||||
@@ -179,6 +102,8 @@ class Function(val definition: Function, override val connection: Connection) :
|
||||
return 0
|
||||
}
|
||||
|
||||
private fun <R : EntityI> compileArgs(value: R): String = compileArgs(listOf(value))
|
||||
|
||||
private fun compileArgs(values: List<Any?>): String {
|
||||
val placeholders = values
|
||||
.filterIndexed { index, value ->
|
||||
@@ -205,4 +130,8 @@ class Function(val definition: Function, override val connection: Connection) :
|
||||
|
||||
return placeholders.joinToString(separator = ", ")
|
||||
}
|
||||
|
||||
private fun <R : EntityI> compileSql(value: R): String = "SELECT * FROM ${definition.name} (${compileArgs(value)})"
|
||||
private fun compileSql(values: List<Any?>): String = "SELECT * FROM ${definition.name} (${compileArgs(values)})"
|
||||
private fun compileSql(values: Map<String, Any?>): String = "SELECT * FROM ${definition.name} (${compileArgs(values)})"
|
||||
}
|
||||
|
||||
@@ -9,101 +9,78 @@ class Query(override val name: String, private val sql: String, override val con
|
||||
return sql
|
||||
}
|
||||
|
||||
/**
|
||||
* Update [EntityI]
|
||||
*/
|
||||
override fun <R : EntityI> update(
|
||||
typeReference: TypeReference<R>,
|
||||
value: R,
|
||||
block: (QueryResult, R?) -> Unit
|
||||
): R? =
|
||||
connection.update(sql, typeReference, value, block)
|
||||
|
||||
/* Select One */
|
||||
|
||||
/**
|
||||
* Select One [EntityI] with [List] of parameters
|
||||
*/
|
||||
override fun <R : EntityI> selectOne(
|
||||
typeReference: TypeReference<R>,
|
||||
values: List<Any?>,
|
||||
block: (QueryResult, R?) -> Unit
|
||||
): R? {
|
||||
return connection.selectOne(this.toString(), typeReference, values, block)
|
||||
}
|
||||
|
||||
inline fun <reified R : EntityI> selectOne(
|
||||
values: List<Any?> = emptyList(),
|
||||
noinline block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(object : TypeReference<R>() {}, values, block)
|
||||
connection.selectOne(sql, typeReference, values, block)
|
||||
|
||||
/**
|
||||
* Select One [EntityI] with named parameters
|
||||
*/
|
||||
override fun <R : EntityI> selectOne(
|
||||
typeReference: TypeReference<R>,
|
||||
values: Map<String, Any?>,
|
||||
block: (QueryResult, R?) -> Unit
|
||||
): R? {
|
||||
return connection.selectOne(this.toString(), typeReference, values, block)
|
||||
}
|
||||
|
||||
inline fun <reified R : EntityI> selectOne(
|
||||
values: Map<String, Any?>,
|
||||
noinline block: SelectOneCallback<R> = {}
|
||||
): R? =
|
||||
selectOne(object : TypeReference<R>() {}, values, block)
|
||||
connection.selectOne(sql, typeReference, values, block)
|
||||
|
||||
/* Select Multiples */
|
||||
|
||||
/**
|
||||
* Select multiple [EntityI] with [List] of parameters
|
||||
*/
|
||||
override fun <R : EntityI> select(
|
||||
typeReference: TypeReference<List<R>>,
|
||||
values: List<Any?>,
|
||||
block: (QueryResult, List<R>) -> Unit
|
||||
): List<R> {
|
||||
return connection.select(this.toString(), typeReference, values, block)
|
||||
}
|
||||
|
||||
inline fun <reified R : EntityI> select(
|
||||
values: List<Any?> = emptyList(),
|
||||
noinline block: SelectCallback<R> = {}
|
||||
): List<R> =
|
||||
select(object : TypeReference<List<R>>() {}, values, block)
|
||||
connection.select(sql, typeReference, values, block)
|
||||
|
||||
override fun <R : EntityI> select(
|
||||
typeReference: TypeReference<List<R>>,
|
||||
values: Map<String, Any?>,
|
||||
block: (QueryResult, List<R>) -> Unit
|
||||
): List<R> {
|
||||
return connection.select(this.toString(), typeReference, values, block)
|
||||
}
|
||||
|
||||
inline fun <reified R : EntityI> select(
|
||||
values: Map<String, Any?>,
|
||||
noinline block: SelectCallback<R> = {}
|
||||
): List<R> =
|
||||
select(object : TypeReference<List<R>>() {}, values, block)
|
||||
connection.select(sql, typeReference, values, block)
|
||||
|
||||
/* Select Paginated */
|
||||
|
||||
/**
|
||||
* Select Multiple [EntityI] with pagination
|
||||
*/
|
||||
override fun <R : EntityI> select(
|
||||
page: Int,
|
||||
limit: Int,
|
||||
typeReference: TypeReference<List<R>>,
|
||||
values: Map<String, Any?>,
|
||||
block: (QueryResult, Paginated<R>) -> Unit
|
||||
): Paginated<R> {
|
||||
return connection.select(this.toString(), page, limit, typeReference, values, block)
|
||||
}
|
||||
|
||||
/* Select Paginated */
|
||||
|
||||
inline fun <reified R : EntityI> select(
|
||||
page: Int,
|
||||
limit: Int,
|
||||
values: Map<String, Any?> = emptyMap(),
|
||||
noinline block: SelectPaginatedCallback<R> = {}
|
||||
): Paginated<R> =
|
||||
select(page, limit, object : TypeReference<List<R>>() {}, values, block)
|
||||
connection.select(sql, page, limit, typeReference, values, block)
|
||||
|
||||
/* Execute function without traitements */
|
||||
/* Execute function without treatments */
|
||||
|
||||
override fun exec(values: List<Any?>): QueryResult {
|
||||
return connection.exec(sql, values)
|
||||
}
|
||||
override fun exec(values: List<Any?>): QueryResult = connection.exec(sql, values)
|
||||
|
||||
override fun exec(values: Map<String, Any?>): QueryResult {
|
||||
return connection.exec(sql, values)
|
||||
}
|
||||
override fun exec(values: Map<String, Any?>): QueryResult = connection.exec(sql, values)
|
||||
|
||||
override fun sendQuery(values: List<Any?>): Int {
|
||||
return connection.sendQuery(sql, values)
|
||||
}
|
||||
override fun sendQuery(values: List<Any?>): Int = connection.sendQuery(sql, values)
|
||||
|
||||
override fun sendQuery(values: Map<String, Any?>): Int {
|
||||
return connection.sendQuery(sql, values)
|
||||
}
|
||||
override fun sendQuery(values: Map<String, Any?>): Int = connection.sendQuery(sql, values)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user