openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ali H. Ibrahim" <>
Subject Integrating Autofetch with OpenJPA
Date Mon, 10 Mar 2008 17:05:25 GMT

I am interested in writing a connector for OpenJPA and Autofetch. 
Autofetch is an open source project I am working on 
( which automatically 
specifies fetch plans for queries. The basic approach is to monitor the 
traversal of query results and "learn" the right fetch plan when you 
execute similar queries in the future. The query result type as well as 
the program stack is used to identify queries and distinguish between 
query invocations in different contexts. The Autofetch web page has an 
example of the software engineering benefits of this approach in 
addition to the simplicity of not having to specify fetch plans. I 
already have a Hibernate connector which works pretty well.

What I am looking for is the appropriate extension points (if available) 
to perform the integration with OpenJPA:

1. I need to intercept entity property accesses (either via field or 
getter access). I need to be able to do this for proxies as well as 
instantiated entities.

2. I need to be able to store some state in proxies / enhanced entities 
and have them implement an additional interface.

3. I need to intercept lazy collection instantiation.

4. I need to be able to store some state in a collection associations 
whether they have been instantiated yet or not.

5. I need to be able to create a fetch plan dynamically for queries, 
finds, etc. I think this is already pretty straightforward in OpenJPA 
(even easier than Hibernate).

For Hibernate, I was able to get points 1,2 by createing a custom 
"tuplizer" which handles instantiating and proxying entities. Points 3,4 
were harder and required hacking around the configuration although I was 
able to do it without duplicating much code and without forking the 
codebase. Point 5 was taken care of by creating custom load listeners 
and wrapping criteria queries, although I have not figured out how to 
deal with HQL queries.

Any help is appreciated.


Ali Ibrahim

View raw message