I’m using Hibernate Criteria API in my project.
In this API, list() method is used to get a number of records from db.
My question is : How to get only one record from db (without using list() method as there is no need)?
I’m using Hibernate Criteria API in my project. In this API, list() method is
Share
If you’re certain that the query is going to return at most one record, use
Criteria#uniqueResult().If the query can return more than one record, but you’re fine with just getting the first result, you could combine
uniqueResult()withCriteria#setMaxResults().