xcesco / kripton

A Java/Kotlin library for Android platform, to manage bean's persistence in SQLite, SharedPreferences, JSON, XML, Properties, Yaml, CBOR.
Apache License 2.0
119 stars 16 forks source link

Query with custom bean as result does not manage custom type fields #104

Closed xcesco closed 3 years ago

xcesco commented 3 years ago

Case study We need to retrieve from a table in a bean type so defined

@BindType
public class FileInfo {
  private final String fileName;
  private final String secret;
  private final DocumentInfo informations;

  public FileInfo(String fileName, String secret, DocumentInfo informations) {
    this.fileName = fileName;
    this.secret = secret;
    this.informations = informations;
  }

  public DocumentInfo getInformations() {
    return informations;
  }

  public String getFileName() {
    return fileName;
  }

  public String getSecret() {
    return secret;
  }
}

Data taken from the following table and data source definition:

@BindDao(Document.class)
public interface DocumentDao extends AbstractDao<Document> {

  @BindSqlSelect(jql = "SELECT fileName, secret, info FROM Documento WHERE assistitoId=:assistitoId and fileName is not null")
  List<FileInfo> selectFilesForAssistito(long assistitoId);

}
@BindSqlType(name = "documents")
public class Document extends AbstractBean {

    private final DocumentInfo info;

    public Document(long id, ZonedDateTime updateTime, DocumentInfo info, ZonedDateTime data, String title) {
        super(id, updateTime);
        this.info = info;
        this.data = data;
        this.title = title;
    }

    public DocumentInfo getInfo() {
        return info;
    }

    public ZonedDateTime getData() {
        return data;
    }

    public String getTitle() {
        return title;
    }

    private final ZonedDateTime data;
    private final String title;

}

The error during annotation processing:

cannot find symbol
if (!_cursor.isNull(index2)) { __info=FileInfoTable.parseInfo(_cursor.getBlob(index2)); }

The other class definitions:

@BindType
public class DocumentInfo {
    private final String bucket1;
    private final String bucket2;

    public String getBucket1() {
        return bucket1;
    }

    public String getBucket2() {
        return bucket2;
    }

    public DocumentInfo(String bucket1, String bucket2) {
        super();
        this.bucket1 = bucket1;
        this.bucket2 = bucket2;
    }

}