我正在尝试使用 ORMLite 将我的类映射到 SQLite 数据库,但我无法存储 String 的集合我有这个错误:
java.lang.IllegalArgumentException: No fields have a DatabaseField annotation in
class java.lang.String
这个错误是不言自明的,但是我应该如何存储字符串集合,我应该扩展 String 类并添加所需的注释来做到这一点?在字段的注释中,我添加了 datatype.serializable 但这也行不通。这是我遇到问题的班级:
@DatabaseTable(tableName = "parameters")
public class Parameters {
// id is generated by the database and set on the object automagically
@DatabaseField(generatedId = true)
int id_parameters;
@DatabaseField(canBeNull = true)
@JsonProperty("id")
private Integer id;
@DatabaseField(canBeNull = false)
@JsonProperty("account_id")
private Integer account_id;
@ForeignCollectionField
@JsonProperty("languages")
private Collection<String> languages;
...
}
有问题的领域是语言!