This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ally Cavs
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • 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. 

 
Roel De Nijs
Sheriff
Posts: 10662
144
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic