Over a million developers have joined DZone.

Autofetch - Eliminate association fetch specifications

DZone's Guide to

Autofetch - Eliminate association fetch specifications

Free Resource
Autofetch addresses a common problem with object relational mapping tools like Hibernate: programmers have to specify the right association fetch strategies. In Hibernate, you can specify these in the configuration files or in queries (fetch joins). If you don't get it right, you can have poor preformance becauase you make too many round-trips to the database. In the worst case you get the n+1 selects problem. Even if the programmer gets the association fetch strategy correct for each query the program's modularity is compromised because changes in the traversal pattern of the program require changes in their correpsonding queries. This is especially apparent when your traversals take place in the view layer and your query code is in the data layer. Now there is an implicit performance dependency between the two.

Autofetch addresses this by automatically adding the right association fetch directives into your queries. It dynamically monitors a program's traversals off of query results and classifies queries to figure out what associations need to be fetched/prefetched. Programs are easier to write and more modular. It is designed to integrate with any object persistence framework, but right now there is only a Hibernate connector. The library is open source LGPL and the website is http://www.cs.utexas.edu/~aibrahim/autofetch/. The details of Autofetch were published in ECOOP 2006. Let me know if you have questions.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}