Friday, February 29, 2008

Automatic Fetch Groups

Seen this article about AutoFetch on TheServerSide.

It is nice to see some some people start to understand limitations of well-known ORM solutions in terms of fetching. Xcalia has a nice solution for this since years, through the notion of "business use-cases".

Through this notion, you can associate runtime behaviours (including fetch groups) to sections of your code. Each section will be called according to the current context definition.

Here is a pseudo-code:
UseCase.start("MinimalEmployee");
Collection employees = getEmployees(pm, lastName);
UseCase.end("MinimalEmployee");


UseCase.start("CompleteEmployee");
employees = getEmployees(pm, lastName);
UseCase.end("CompleteEmployee");

In the first case, the getEmployees() method will just retrieve the name of employees, while in the second case it will retrieve all employee information, including related objects and collections.

Use cases can be defined statically in properties files, but they can also be modified at runtime through the JMX interface. This mechanism is not limited to queries and can also be applied during transparent navigation between objets.

It seems AutoFetch author claims to be able to automates the definition of dynamic fetch plans. The details should be available in this paper.

No comments:

Post a Comment