开发者

Efficient way of Retrieving data for multiple rows simultaneously

开发者 https://www.devze.com 2023-04-11 09:31 出处:网络
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

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);

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号