What is a Fetching Strategy?

375 views Asked by At

I understand the core concept of retrieving data using different strategies. But I cannot find a good summary/definition..

  • Is it a design pattern? Does it fit within a broader design pattern?
  • Is it specific to ORM implementations? (Hibernate comes up a lot)
  • What does it do? Does (should) it return a collection of Value Objects, or ...anything you want?
  • Are there common classes and methods associated with one?
1

There are 1 answers

0
sdg On BEST ANSWER

I am not sure that Fetching Strategy is a design pattern on its own, but is indeed part of a class of patterns. Two examples would be Lazy Loading and prefetching. Another related concept would be caching.

They are not specific in any way to ORM or Hibernate, but are often mentioned there as you need to configure the tool to act in a specific way, as opposed to coding it directly.

Overall, your fetching strategy controls how you retrieve data into your application, and may (or may not) affect how objects are instantiated in your application for an OO language.

If, for example, you normally walk through an entire data set (or set of objects), then it may well be more efficient to load an entire set at once, or to effectively prefetch the data so it is ready to process.

On the other hand, if you often only access the first part of data; or perhaps the envelope of an object instead of its content, you may chose to only instantiate the top-level part of an object hierarchy instead of all its contents.