gpt4 book ai didi

java - Room 无法检索以下列

转载 作者:行者123 更新时间:2023-12-02 01:37:14 25 4
gpt4 key购买 nike

这是实体,但我没有发现此页面有任何问题。我能听懂这个词,但听不懂其他 4 列。 @Entity(表名 = "单词")公共(public)类模型{

@PrimaryKey
@ColumnInfo(name = "_id")
private int id;
@ColumnInfo(name = "en_word")
private String en_word;
@ColumnInfo(name = "en_definition")
private String en_definition;
@ColumnInfo(name = "example")
private String example;
@ColumnInfo(name = "synonyms")
private String synonyms;
@ColumnInfo(name = "antonyms")
private String antonyms;

public int getId() {
return id;
}

public void setId(int id) {
this.id = id;
}

public String getEn_word() {
return en_word;
}

public void setEn_word(String en_word) {
this.en_word = en_word;
}

public String getEn_definition() {
return en_definition;
}

public void setEn_definition(String en_definition) {
this.en_definition = en_definition;
}

public String getExample() {
return example;
}

public void setExample(String example) {
this.example = example;
}

public String getSynonyms() {
return synonyms;
}

public void setSynonyms(String synonyms) {
this.synonyms = synonyms;
}

public String getAntonyms() {
return antonyms;
}

public void setAntonyms(String antonyms) {
this.antonyms = antonyms;
}

}

这是来自 DAO 的查询

@Query("SELECT en_definition, example,synonyms,antonyms FROM words WHERE UPPER(:text)")
Cursor getMeaning(String text);

这来自 Activity

 Cursor c = application.getmDatabase().wordsDao().getMeaning(enWord);
Log.d(TAG, enWord);

if (c.moveToFirst()) {

enDefinition= c.getString(c.getColumnIndex("en_definition"));
example=c.getString(c.getColumnIndex("example"));
synonyms=c.getString(c.getColumnIndex("synonyms"));
antonyms=c.getString(c.getColumnIndex("antonyms"));

Log.d(TAG, enDefinition); //no output

}

我可以记录 enWord,但无法到达其中的 4 列。它在数据库帮助程序类中工作正常,但没有空间输出。

最佳答案

请将您的查询编辑为:

@Query("SELECT en_definition, example, synonyms, antonyms FROM words WHERE en_word = UPPER(:text)")
Cursor getMeaning(String text);

关于java - Room 无法检索以下列,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55070262/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com