将对象列表绑定到 JDBI SQL。科特林
我有一个数据对象列表,如下所示:
data class Detail (
val type1: Type1
val type2: Type2
)
val list: List<Detail> = arrayListOf(Detail,Detail,Detail)
如何将详细信息列表绑定到 JDBI SQL 查询中。我知道如何使用单一数据类型来完成此操作,但只是不确定当您从“详细信息”数据类获取属性时这是如何工作的。
例如:
it.createQuery(
"""
SELECT
id
FROM
tbl_of_something
WHERE
type1
AND
type2
IN (<detail>)
"""
).bindList("detail", list)
.mapTo(String::class.java)
.toSet()
.toList()
.sorted()
I have a list of data object that looks as follows:
data class Detail (
val type1: Type1
val type2: Type2
)
val list: List<Detail> = arrayListOf(Detail,Detail,Detail)
How do I bind the the list of details into a JDBI SQL query. I know how to do it with a single data type but just not sure how this works when you are getting properties from the "Detail" data class.
eg:
it.createQuery(
"""
SELECT
id
FROM
tbl_of_something
WHERE
type1
AND
type2
IN (<detail>)
"""
).bindList("detail", list)
.mapTo(String::class.java)
.toSet()
.toList()
.sorted()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

我发现,这可以通过使用bindBeanList()来解决,如下所示:
I figured it out, this can be solved by using bindBeanList() as follows: