开发者

findall hibernate or Criteria and Example

In Hibernate, what is the best approach:

  1. to use findAll for datatable objects, return all the fields and extract only the relevant data, or use Criteria and Example to focus the results and the columns?
  2. if the answer is based 开发者_StackOverflow社区on table size - from which columns amount and row amount is it recommended to use each approach?


I think only you can decide which approach to take based on your application.

  1. If you need a data from each object in the datatable it would be alot easier to retrieve all objects and extract the relevant data. If this incurs a sufferable performance overhead, then hibernate offers a bunch of optimizations to extract the data you need. Remember that reading columns is alot faster than reading rows. One such optimization could be to extract a list of id's which can be iterated over by the application which fetches the entries one by one, incurring an almost zero memory overhead with some tradeoff to the number of transactions.

  2. There is generally no recommended limit as it all depends on your application and table size. I would probably find another way if I the query spans over 10k objects, mostly due to memory concerns.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜