This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Fetch data using single select statement in HQL (Many to One relationship)  RSS feed

sameer verma
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have two entities student and college. A single college has multiple student.

I want to fetch all the students of a particular college.

As you can see in below code the HQL query I have written is : "select student from "+Student.class.getName()+" student where = 1"

On execution of following code I two SQL queries are fired as follows:

Ideally first query is sufficient to fetch all required students and it is working well when I fire directly from database.

why second query is executed? How can I stop Hibernate by executing this extra query?
Utility class:

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!