Soru & Cevap

Android error: Cannot find getter for field. hatası

19.03.2019 - 11:21

Aşağıdaki kodlarda 

private long id; satırında hata alıyorum

 


@ColumnInfo(name = ID) @PrimaryKey(autoGenerate = true)

private long id;

@ColumnInfo(name = CREATION_DATE)

private Date creationDate;
 

394 Görüntülenme

2 Cevap

Sitedeki sorulara cevap verebilmek için giriş yapın ya da üye olun.

picture-40238-1450213783.jpg
pecenek.enes
14.11.2019 - 12:26

Tek yapman gereken  publi long id; yapman gerekir bu işlemin ardından  hata gidecektir.

 

Profile picture for user polatyener_csharp
polatyener_csharp
19.03.2019 - 11:23
Kodların Tamamı aşağıdaki gibidir

public class SearchHistoryEntry {

    public static final String ID = "id";
    public static final String TABLE_NAME = "search_history";
    public static final String SERVICE_ID = "service_id";
    public static final String CREATION_DATE = "creation_date";
    public static final String SEARCH = "search";

    @ColumnInfo(name = ID)
    @PrimaryKey(autoGenerate = true)
    private long id;

    @ColumnInfo(name = CREATION_DATE)
    private Date creationDate;

    @ColumnInfo(name = SERVICE_ID)
    private int serviceId;

    @ColumnInfo(name = SEARCH)
    private String search;

    public SearchHistoryEntry(Date creationDate, int serviceId, String search) {
        this.serviceId = serviceId;
        this.creationDate = creationDate;
        this.search = search;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Date getCreationDate() {
        return creationDate;
    }

    public void setCreationDate(Date creationDate) {
        this.creationDate = creationDate;
    }

    public int getServiceId() {
        return serviceId;
    }

    public void setServiceId(int serviceId) {
        this.serviceId = serviceId;
    }

    public String getSearch() {
        return search;
    }

    public void setSearch(String search) {
        this.search = search;
    }

    @Ignore
    public boolean hasEqualValues(SearchHistoryEntry otherEntry) {
        return getServiceId() == otherEntry.getServiceId() &&
                getSearch().equals(otherEntry.getSearch());
    }
}