Efficient way of Retrieving data for multiple rows simultaneously
When we tried to retrieve data for a arraylist, we are iterating each row and开发者_开发百科 then we are using fetch query.is there any other iteration row in hibernate template or sql
for (RequestObjRel reqObjRel : requestObjRelList) {
String sqlQuery = "from Ce where cerId = '"
+ reqObjRel.getCed()
+ "' and trbr = "
+ reqObjRel.getCNbr();
List<Certificate> certDetailList = dao
.retrieveTableData(sqlQuery);
}
I could not find efficient way to retrieve data
You can make an HQL query that uses the IN
clause and thus fetch multiple objects with one query. Something like:
from Foo foo where foo.id in (:fooIds)
Then you set the parameter on the Query
object: query.setParameter("fooIds", listOfIds);
精彩评论