ORMLite尝试在没有@DatabaseField注释的情况下加载字段

时间:2017-09-13 20:40:38

标签: android sqlite ormlite

我有两个类如下:

@Getter
@Setter
@NoArgsConstructor
@DatabaseTable(tableName = "condicao_ambiental")
public class CondicaoAmbiental {
    @Expose
    @DatabaseField(id = true, columnName = "id")
    private UUID id;
    @Expose
    @DatabaseField(dataType = DataType.DATE_LONG)
    private Date dataCriacao;
    @Expose
    @DatabaseField(columnName = "idUsuario", foreign = true, foreignAutoRefresh = true)
    private Usuario usuario;
    ...
}   

@Getter
@Setter
@NoArgsConstructor
@DatabaseTable(tableName = "usuario")
public class Usuario {
    @Expose
    @DatabaseField(id = true, columnName = "id")
    private UUID id;
    @DatabaseField(foreign = true, columnName = "idCliente")
    private Cliente cliente;
    @DatabaseField
    private String nome;
    @DatabaseField
    private String login;
    private String senha;
    ...
}

这些类中使用的注释来自LombokRetrofit2OrmLite5

当我查询列出CondicaoAmbiental时,会出现此错误:

java.sql.SQLException: Unknown field 'senha' from the Android sqlite cursor, not in:[id, idCliente, nome, tipoSindicato, dataCadastro, diasTeste]

但是列senha未注释为字段。

当我查询列出Usuario时,一切运行正常并且列表已加载。 如果我从字段foreignAutoRefresh=true中删除usuario,则不会发生错误。

有人能告诉我我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

正如Gray所解释的,解决方案只是重新编译项目,以便ORMLite可以重新生成配置文件。