Here's the patch and a new file. When putting in the new code I tried to just splice it in gently so it would be easy to update from CVS later and also would not affect OJB at all if you don't use the functionality, so it might not be integrated quite as nicely as you'd expect. As I mentioned the first time I submitted this I don't think it handles extents correctly, and maybe some other things, but it does work quite well for what I'm using it for. This app has one object per table and mostly just plain fk references. See the messages linked to below for more info. If I have time I'd be happy to help work on any of these issues.
To use, you'd use a QueryByCriteriaMultiJoin instead of regular query. The
"extraJoin"s you add are relationship path names, any depth. Querying on A,
with a relationship to B named "relB", where B has one to C ("relC"), you
could add extra joins for "relB" and "relB.relC". The query would return all
fields from tables a, b, and c and build the objects B and C that A
references. When accessing a.getB().getC() the objects are already loaded and
there's no extra queries - just the one original query on A. This works best
with one-to-one relationships, or if you select from the many side of a
one-to-many. You just have to be aware of what's going on since there's going
to be table joining going on in order to get the extra fields.
Hope that makes sense. I just updated 5pm CST 2003-08-21 and that's what the
diff is based on.
John Marshall
Connectria
>===== Original Message From Jakob Braeuchi <[EMAIL PROTECTED]> =====
>hi john,
>
>could you please send it to me as well ?
>
>jakob
>
>John M wrote:
>
>>I submitted a patch earlier that allows a different method of prefetching
>>related objects and does indeed allow prefetching for more than one level
>>deep. All data is returned in one query by joining tables and getting all
>>fields for the related objects. The patch files were based off what I got
out
>>of cvs and aren't based on the tagged rc4, so I'll have to update the patch
>>for you if you are interested.
>>
>>I think deep prefetching is useful for our app, which at times needs to load
a
>>large set of data for some analysis and optimization and the whole object
>>graph is useful. It is also useful for many reports.
>>
>>The patch was included on this message:
>>http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]&m
sgId=752859
>>
>>and described here:
>>http://nagoya.apache.org/eyebrowse/[EMAIL PROTECTED]&m
sgId=751991
>>
>>
>>John Marshall
>>Connectria
>>
>>
>>
>>>===== Original Message From "OJB Users List" <[EMAIL PROTECTED]> =====
>>>Hello,
>>>
>>>
>>>
>>>-----Original Message-----
>>>From: Jakob Braeuchi [mailto:[EMAIL PROTECTED]
>>>
>>>
>>>prefetching currently works only for one level . the prefetcher looks
>>>for a relationship named
>>>
>>>"allb.singlec" in A.class in your sample. the query criteria
>>>has no effect on prefetching.
>>>i'm not sure whether deep prefetching is really useful.
>>>
>>>
>>>Such a feature would really make me happy. What do you think,
>>>is it difficult to implement? Are there other people
>>>having that need?
>>>
>>>Olli
>>>
>>>
>>>
>>>>Does anyone know if prefetched relationships can reach more
>>>>
>>>>
>>>than one "layer"
>>>
>>>
>>>>of references/collections from an class being queried?
>>>>E.g. If I have a class A that I an querying and it has a 1:m
>>>>
>>>>
>>>relationship
>>>
>>>
>>>>with some class B, with the relationship defined by the name "allb",
>>>>and then each B has 1 1:1 relationsbip with another class C, with the
>>>>relationship called "singlec", is the following supposed to work:
>>>>
>>>> Criteria criteria = new Criteria();
>>>> // configure the criteria
>>>> ...
>>>>
>>>> // add prefetched relationships
>>>> criteria.addPrefetchedRelationship("allb");
>>>> criteria.addPrefetchedRelationship("allb.singlec");
>>>>
>>>> Query q = QueryFactory.newQuery( A.class, criteria);
join-load.zip
Description: Zip compressed data
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
