Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JPA Criteria

 
Ron Patel
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having a problem with JPA/Hibernate that is driving me crazy and was wondering if anyone could help.

I am running a JPA query using Hibernate criteria. I create a Criteria using the JPA runtime's underlying Session.

However, when this criteria runs, I see that JPA runs my criteria first and fetches the correct data. Then, before returning to me, it goes out to the database a second time to fetch every piece of data there, including things that do not match the criteria.

This occurs when I have the FetchMode set to EAGER or LAZY; it doesn't matter.

Has anyone ever encountered this behaviour before? Is there any way around this?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic