• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Why does FetchType influence number of results!?!

 
Jimmy DeMonstah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
OK, I'm missing something obvious here.

I'm using JPA / Spring / Hibernate. Mostly it's all working fine. But I am finding that a FetchType of LAZY or EAGER actually influences the number of results that are returned from a query. In my understanding, this should not be the case; LAZY/EAGER should *only* influence the timing of when an association is queried for.

I have a simple parent/child relationship to order header and order details as follows:



and


When I do a simple findAll using a basic DAO pattern, I get a few dozen results, as expected. However, if I change the FetchType to EAGER in the OrderHeader class, I get several thousand results; even MORE than the combined total of headers + details. What gives?
 
aditee sharma
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you take a look at the generated mapping files from these annotations ?
That would be the first place I'd look at.
 
Jimmy DeMonstah
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Annontated classes don't generate xml mappings... you're thinking of xDoclet perhaps?

My grasping at straws guess is that because the parent and child are mapped to each other, each (EAGER) call to load the child in return also tries to load the parent as another instance. But why this would ever be desirable is beyond me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic