db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brian McCallister <mccallis...@forthillcompany.com>
Subject Reference Fetching and Joins in 1.1
Date Fri, 16 Apr 2004 12:40:40 GMT
A couple thoughts on the JDBC access and collection fetching/proxying 
going forward:

First is the ability to programmatically define auto-retrieves via 
something like:

QueryByCriteria query = QueryFactory.newQuery(Foo.class, new 
query.prefetch("foo.bar, foo.bar.waffle, foo.eggs");

This would specify to retrieve the bar collection on foo, the waffle 
collection on each instance in bar, and the eggs collection on foo, 
regardless of what the mapping metadata says.

Second, and Jakob shot me down on this once (but I'm going to try again 
anyway), is retrieving referenced collections via a join:

foo.bar can be done via:

select foo.id, foo.prop, bar.id, bar.fooId, bar.prop from foo left 
outer join bar on foo.id = bar.fooId;

as well as the current:

select foo.id, foo.prop from foo;
select bar.id, bar.prop, bar.fooId from bar where bar.fooId = ?;

It gets entertaining to construct objects from the results, but the 
ability to fetch via the join is usually a benefit over multiple 
queries -- when the database supports the left outer join. The queries 
also get entertaining when you have collections on bar which should 
also be in the same join.

The behavior of how to retrieve a referenced collection (join vs 
separate select) should be in metadata, and joins would need to be 
quietly converted to multiple selects on platforms where outer joins 
are not supported.

Thoughts, opinions?


To unsubscribe, e-mail: ojb-dev-unsubscribe@db.apache.org
For additional commands, e-mail: ojb-dev-help@db.apache.org

View raw message