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

Inner Join in HQL

 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,

The query below fails. Any reasons why?

queryStr = "select distinct c from Content c INNER JOIN ContentFeedback cf " +
"ON c = cf.content " +
"where cf.user = :user";
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the error message? How does it fail?
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Invalid token ON...I changed my query to use a where clause instead of Inner Join and it worked fine. But I want to know why I'm not able to use Inner Join...ON syntax??
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HQL doesn't support that syntax. Think about it - it doesn't need to. Your mapping already defines the association, all you are doing with your HQL is eagerly fetching the associated object. Have a read of the HQL documentation for the correct syntax.
 
Joe Harry
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:
HQL doesn't support that syntax. Think about it - it doesn't need to. Your mapping already defines the association, all you are doing with your HQL is eagerly fetching the associated object. Have a read of the HQL documentation for the correct syntax.


Thanks Paul!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic