Error @DatabaseField + Abstract class ORMLite (java.lang.IllegalArgumentException: No fields have a DatabaseField annotation in class ***. Object)

2

I have a class that extends from the object class (abstract) from which I need to save the fields in the database, but the ormlite asks the object class to have some field with the @DatabaseField annotation only that I do not need to save anything of the object class, only serves as an internal app standard.

Object class:

/**
 * Classe abstrata que modela qualquer objeto do sistema.
 */
public abstract class Objeto {

    /**
     * Tipo de objeto-classe
     */
    protected String classType;

    /**
     * Obtem a classe do objeto
     * @return classe do objeto
     */
    public String getClassType() {
        return classType;
    };

    /**
     * Obtem o identificador do objeto
     * @return identificador
     */
    public abstract Object getId();

}

Class I need to save:

@Sincronizavel
@DatabaseTable(tableName = "sf_pergunta_mais2anos")
public class SfPerguntaMais2Anos extends Objeto {

    @JsonProperty("id")
    @DatabaseField(columnName = "id", id=true)
    private String id;
    @JsonProperty("pergunta")
    @DatabaseField(columnName = "pergunta")
    private Integer pergunta;
    @JsonProperty("resposta")
    @DatabaseField(columnName = "resposta")
    private Integer resposta;
    @JsonBackReference
    @JsonProperty("fichaAlimentacao")
    @DatabaseField(columnName = "ficha_alimentacao", canBeNull=false, foreign=true, foreignAutoRefresh=true, maxForeignAutoRefreshLevel=2)
    private SfCadastroConsumoAlimentar ficha;
    @JsonManagedReference
    @ForeignCollectionField(eager = true)
    @JsonProperty("sfmultiplasresp")
    private Collection<SfMultiplasResp> multiplasResp;

    /**
     * Construtor padrao - necessario ao ORMLITE
     */
    public SfPerguntaMais2Anos() {
        classType = "SfPerguntaMais2Anos";
        id = Utils.obterInstancia().getUniquePseudoUUID();
    }

    public SfPerguntaMais2Anos( String uuid ) {
        classType = "SfPerguntaMais2Anos";
        id = uuid;
    }

    @Override
    public String getId() {
        return id;
    }

}

Error:

06-21 15:34:57.179: W/System.err(24713): java.lang.IllegalArgumentException: No fields have a DatabaseField annotation in class ***.modelo.Objeto
06-21 15:34:57.179: W/System.err(24713):    at com.j256.ormlite.table.DatabaseTableConfig.extractFieldTypes(DatabaseTableConfig.java:249)
06-21 15:34:57.179: W/System.err(24713):    at com.j256.ormlite.table.DatabaseTableConfig.fromClass(DatabaseTableConfig.java:176)
06-21 15:34:57.179: W/System.err(24713):    at com.j256.ormlite.table.TableInfo.<init>(TableInfo.java:55)
06-21 15:34:57.179: W/System.err(24713):    at com.j256.ormlite.dao.BaseDaoImpl.initialize(BaseDaoImpl.java:156)
06-21 15:34:57.179: W/System.err(24713):    at com.j256.ormlite.dao.BaseDaoImpl.<init>(BaseDaoImpl.java:133)
06-21 15:34:57.179: W/System.err(24713):    at com.j256.ormlite.dao.BaseDaoImpl.<init>(BaseDaoImpl.java:112)
06-21 15:34:57.179: W/System.err(24713):    at com.j256.ormlite.dao.BaseDaoImpl$5.<init>(BaseDaoImpl.java:1044)
06-21 15:34:57.179: W/System.err(24713):    at com.j256.ormlite.dao.BaseDaoImpl.createDao(BaseDaoImpl.java:1044)
06-21 15:34:57.180: W/System.err(24713):    at com.j256.ormlite.dao.DaoManager.createDao(DaoManager.java:70)
06-21 15:34:57.180: W/System.err(24713):    at com.j256.ormlite.android.apptools.OrmLiteSqliteOpenHelper.getDao(OrmLiteSqliteOpenHelper.java:277)
06-21 15:34:57.180: W/System.err(24713):    at ***.persistencia.DatabaseHelper.obterDAO(DatabaseHelper.java:359)
06-21 15:34:57.180: W/System.err(24713):    at ***.sincronia.eSusSyncAdapter.obterListaLocal(eSusSyncAdapter.java:428)
06-21 15:34:57.180: W/System.err(24713):    at ***.familia.sincronia.eSusSyncAdapter.sincronizarObjeto(eSusSyncAdapter.java:226)
06-21 15:34:57.180: W/System.err(24713):    at ***.sincronia.eSusSyncAdapter.onPerformSync(eSusSyncAdapter.java:119)
06-21 15:34:57.180: W/System.err(24713):    at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259)
    
asked by anonymous 21.06.2018 / 20:39

0 answers