I have a requirement to write a QueryDSL to fetch the lastest record in the table.To achieve this,i sort in descending order based on timeCreated and i am using singleResult to fetch the first record.
Object obj;
Object result = (Object) query.from(table)
.where(CLAUSE)
.orderBy(timeCreated.desc())
.singleResult(obj);
I needed a clarification if the above(singleResult) would always fetch the first record in the sorted list(latest record)
From the querydsl 3 docs for singleResult
:
For multiple results only the first one is returned
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.