查询表中的最后一个id

Inx*_*Inx 5 query-builder ormlite

我需要获取表格中最后一条记录的ID.我试过了:

Dao<ParticipantModel,Integer> participantDao  = getHelper().getParticipantsDao();
        participant = participantDao.query(participantDao.queryBuilder()
                 .orderBy("id", false).prepare()).get(1);
Run Code Online (Sandbox Code Playgroud)

我不知道如何使用它QueryBuilder来获得我正在寻找的结果.提前感谢任何想法.

Mar*_*Nuc 8

在我的应用程序中我做同样的事情只是将limit(int)添加到准备好的查询中,如下所示:

Dao<ParticipantModel,Integer> participantDao  = getHelper().getParticipantsDao();
    participant = participantDao.query(participantDao.queryBuilder()
         .orderBy("id", false).limit(1L).prepare());
Run Code Online (Sandbox Code Playgroud)