• 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
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Hibernate Inner Join with AND criteria

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello All,

SQL :
SELECT p.id, p.name, s.id, s.name, c.name from Product As p inner join supplier as s On p.supplierid =s. supplierid and s. compayid=1 inner join customer as c on p.customerid=c.customerid and c. compayid=1

I do not want to use where close in above SQL

HQL (Working):
SELECT p.id, p.name, s.id, s.name, c.name from Product p inner join p.supplier as s inner join p.customer as c

I had tried

SELECT p.id, p.name, s.id, s.name, c.name from Product p inner join p.supplier as s and s. compayid=1 inner join p.customer as c and c. compayid =1

But Exception “unexpected token: and”

Can anyone help me to add ‘and s.compayid =1’ clause in above HQL to get it work.

Regards
Ram Mandavkar
 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you already tried to use the "with" keyword? I'm not sure if this keyword might work cause I never had used it in inner joins. Try somethink like the folowing as a matter of taste...

 
Ram Mandavkar
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Victor,

Thanks for suggestion
I was using Hibernate 3.0 which is not supported 'WITH' KEYWORD

as per Hibernate 3.1.3 Released
http://www.roseindia.net/hibernate/hibernate3.1.3.shtml
** Improvement
* [HHH-1520] - with clause with implied joins within an explicit join

It works with Hibernate 3.1.3

I had changed Hibernate 3.0 with Hibernate 3.1.3
and it works

Thanks again


 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic