0

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

leppie
  • 115,091
  • 17
  • 196
  • 297
HukeLau_DABA
  • 2,384
  • 6
  • 33
  • 51

1 Answers1

1

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

AbcAeffchen
  • 14,400
  • 15
  • 47
  • 66
Blums
  • 26
  • 2