Search code examples
androidsqliteormlite

ORMLite trying to load field without @DatabaseField annotation


I have 2 classes like following:

@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;
    ...
}   

and

@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;
    ...
}

The annotations used in these classes are from Lombok, Retrofit2 and OrmLite5

When I make a query to list CondicaoAmbiental this error is presented:

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

But the column senha is not annotated as field.

When I make a query to list Usuario, everything runs OK and the list is loaded. If I remove the foreignAutoRefresh=true from field usuario, no error occurs.

Could someone tell me what am I missing?


Solution

  • As explained by Gray, the solution is just recompile the project so the ORMLite can re-generate the config file.