Kotlin-在多行查询中注入Android Room SQL语言 [英] Kotlin - Inject Android Room SQL language on multiple line queries
问题描述
如何获取要插入的多行查询?它可以在带有Java类的Room上使用,但是Kotlin也支持吗?
How can I get multi-line queries to be injected? It works on Room with Java classes, but does Kotlin support this as well?
例如我在这里有2个查询,只有顶部的SQL查询(1行)会被注入.
E.g. I have 2 queries here, and only the top SQL query (1 line) gets injected.
我尝试遵循本指南中的步骤,但是可以找不到所需的设置.
I tried to follow the steps in this guide but could not find the required settings.
在 https://youtrack.jetbrains.com/issue/KT-13636上存在问题表示此问题已解决,但我不确定如何实施此修复程序.
There is an issue at https://youtrack.jetbrains.com/issue/KT-13636 which suggests this is fixed, but I'm not sure how to implement the fix.
推荐答案
您可以使用原始字符串,该字符串反而更易读:
You can use a raw string which is more readable anyway:
@Dao
interface ItemDao {
@Query("""
SELECT * FROM Item
WHERE Item.id = :id
""")
fun loadItemById(id: Long): LiveData<Item>
}
这篇关于Kotlin-在多行查询中注入Android Room SQL语言的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!