• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

JPA Left Join Eager Fetch fetches again with a select if child row doesnt exits

 
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Guys

Im doing a LEFT JOIN FETCH in a named query. Result data is as expected. In some cases, parent records wont exist as a foriegn key on the child table. For each parent that doesnt exist on child table JPA does an additional select for this manytoone unidirectional mapping


For parent table where a parent ID does not exist in child row, then JPA does an additional select


How can I stop this additional select. If my search criteria brings back parent rows that all exist as a foreign key on the child table, the additional selects does not happen. If I have 5 parents rows out of result list of 10 that don't exist on child table as a foreign key I will have 5 additional selects.  

 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And which persistence provider (and version) are you using?
 
Ally Cavs
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java 1.8
javax.persistence.

org.hibernate
hibernate-entitymanager
4.2.6-FINAL

org.hibernate
hibernate-core
4.2.6-FINAL

org.hibernate.javax.persistence
hibernate-jpa-2.0-api
1.0.1.FINAL

I would have assumed this was a common issue but I cnat find anything on the net
 
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic