我正在使用带有kotlin的android持久性库房间.
Dao看起来像这样
@Dao
interface CountryDao {
@Query("SELECT * FROM countries")
fun loadAllCountried() : LiveData<List<CountryEntity>>
@Insert(onConflict = OnConflictStrategy.REPLACE)
fun insertAll(products: List<CountryEntity>)
@Query("SELECT * FROM countries WHERE id = :countryId")
fun loadCountry(countryId: Int): LiveData<CountryEntity>
@Query("SELECT * FROM countries WHERE id = :countryId")
fun loadCountrySync(countryId: Int): CountryEntity
}
Run Code Online (Sandbox Code Playgroud)
这对我来说似乎很好,但我收到了这个错误
Error: Each bind variable in the query must have a matching method parameter. Cannot find method parameters for :countryId.
我可以看到参数被命名为countryId,那么可能是什么问题?
仅供参考:这是CountryDao_Impl.java中的生成代码
@Override
public CountryEntity loadCountrySync(int arg0) {
final String _sql = "SELECT …Run Code Online (Sandbox Code Playgroud)