I read that activeandroid generates ids for every record inserted.
I want to retrieve records from latest created to earliest created. I know to use orderBy(COL_NAME, DESC), where COL_NAME is the primary key column, but what is that column name?
I know I can create a pseudo primary key:
@Column(name = "id", unique = true, onUniqueConflict = Column.ConflictAction.REPLACE)
public long id;
and do
orderBy("id DESC").execute()
but I feel it's wasteful when I could just use the real primary key
From the Active Android Github Side:
One important thing to note is that ActiveAndroid creates an id field for your tables. This field is an auto-incrementing primary key.
In your case you could delete your @Column
and it will work fine.
Source:
https://github.com/pardom/ActiveAndroid/wiki/Creating-your-database-model