How to get Last 10 records from OrmLite?

GeniDeveloper

With ormLite I can get all record with :

myDao.queryForAll();

How can I get only the first 10 records and not all records ?

tim.paetz

You will have to use QueryBuilder and set the limit. Here's the javadoc reference: http://ormlite.com/javadoc/ormlite-core/com/j256/ormlite/stmt/QueryBuilder.html#limit%28java.lang.Long%29

This is give or take what the code will look like:

QueryBuilder<MyDataObject, String> builder = myDao.queryBuilder();
builder.limit(10);
builder.orderBy("columnName", true)  // true for ascending, false for descending
List<MyDataObject> list = myDao.query(builder.prepare());  // returns list of ten items

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to get last records with conditions from SQLite?

From Dev

Spring Data JPA Java - get Last 10 records from query

From Dev

Spring Data JPA Java - get Last 10 records from query

From Dev

How to get last 10 mins records using linq?

From Dev

how to get last 10 added records in sqlite table in iphone

From Dev

How to get the last 10 messages from the mongodb?

From Dev

Get records from last hour

From Dev

How to get last inserted records

From Dev

get last 30 records from mongoDB

From Dev

MySQL get last date records from multiple

From Dev

Get records from last 6 Months MySQL

From Dev

Get records from last 7 days

From Dev

MySQL get last date records from multiple

From Dev

How to get the last 5-10 message from a database?

From Java

How to get the last N records in mongodb?

From Dev

How to get first and last records between groups?

From Dev

How to get first and last records between groups?

From Dev

How to skip last 2 records and get all other records with linq?

From Dev

How to take last records from list

From Dev

how to get last 20 min active records from a table which is having user login date with time

From Dev

How to get records from SQL

From Dev

How to get records from SQL

From Dev

Oracle SQL get the first and last records from an ordered dataset

From Dev

Get records from last hour or last 20 items if there is none in the last hour

From Dev

how to get last 10 and then show random 5

From Dev

How to get the table name in OrmLite

From Dev

How to get first and last records grouping by a certain column?

From Dev

how can get last ID after UPDATING records?

From Dev

how can get last ID after UPDATING records?

Related Related

HotTag

Archive