Sirisha (and OpenJPA committers please read!),

After some searching I found that I had already reported this problem 18 months 
ago 
http://openjpa.208410.n2.nabble.com/N-1-select-problem-with-related-entities-inside-a-OneToOne-or-ManyToOne-field-td6073663.html
 I didn't create a Jira issue back then because I could work around my problem.

In this example I took an example of the OpenJPA documentation where they have 
a structure like:
Company (OneToMany)  Employee (OneToMany) Project

When querying for Company, OpenJPA uses 3 queries to fetch all reachable 
Employees and Projects, regardless of how many Employees and Projects there are.

However when I change the relation from Company to OneToOne (I think ManyToOne 
has the same effect), OpenJPA starts loading individual Employees with 
individual queries:

.... 
2905  testPU  TRACE  [main] openjpa.jdbc.SQLDiag - load field: 'projects' for 
oid=467 class entities.Employee 
2905  testPU  TRACE  [main] openjpa.jdbc.SQL - <t 23117648, conn 1247640> 
executing prepstmnt 1830320 SELECT t0.id, t0.name FROM Project t0 WHERE 
t0.EMPLOYEE_ID = ? [params=?] 
2906  testPU  TRACE  [main] openjpa.jdbc.SQL - <t 23117648, conn 1247640> [0 
ms] spent 
2907  testPU  TRACE  [main] openjpa.jdbc.SQLDiag - load field: 'projects' for 
oid=468 class entities.Employee 
2907  testPU  TRACE  [main] openjpa.jdbc.SQL - <t 23117648, conn 1247640> 
executing prepstmnt 26341410 SELECT t0.id, t0.name FROM Project t0 WHERE 
t0.EMPLOYEE_ID = ? [params=?] 
....

In my real application I have a complicated graph for a reservation of multiple 
rooms with a customer with contacts and many product order lines and related 
products and many more related entities. This problem occurs at different 
places in the object graph (below the Customer entity and below the order line 
entity) and s really killing the performance of the most important entity in 
our application because it can take about 3.5 seconds to fetch a single 
relatively simple reservation. It is especially bad when making a report on 
multiple reservations based on a time range OpenJPA query.

My complex graph also seems to suffer from a "load field" problem that may be 
caused by ProductOrderLine having a parent-child relation to itself ("package 
deals"), not sure if this is an instance of the same problem.

Can someone from OpenJPA at least look into this issue? If necessary I can 
create a JIRA issue with the simple Company - Employee - Project structure.

Regards,
Henno

-----Oorspronkelijk bericht-----
Van: Sirisha Chiruvolu [mailto:chsiri...@gmail.com] 
Verzonden: woensdag 7 november 2012 18:02
Aan: users@openjpa.apache.org
Onderwerp: RE: Fetchgroups recursion problem

Henno,

Thanks for your response.

Yes my concern is c is getting fetched with more queries(N+1), rather being
fetched along with A.

Thanks
Sirisha



--
View this message in context: 
http://openjpa.208410.n2.nabble.com/Fetchgroups-recursion-problem-tp3874382p7581654.html
Sent from the OpenJPA Users mailing list archive at Nabble.com.

Reply via email to