• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Hibernate 3 not able to recognize the "ON" word in sql

 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,

Am using hibernate with MSSQL where am having a query which is joining 4 tables with "ON" condition

Its giving an error at "ON" condition even I checked "WITH" condition but failed even with that.
But the same code is working in MSSQL properly, so the problem is with Hibernate
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How are you running this bit of SQL? Are you running it as a SQL query?
 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in MSSQL console am running as query but where as in hibernate its giving error telling "Invalid token ON".
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, what I mean is which Hibernate method are you using to run this bit of SQL.
 
Kartik Tal
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is the way i had used



 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok. Well Hibernate's query language is HQL not SQL (have a read of the documentation). If you want to run proprietory SQL you will need to run it ass a sql query (check the JavaDocs for the Session class).

One thing to think about though: one of the reasons you use a tool like Hibernate is to avoid tighly coupling your data access code to a specific database, which is what you do when you introduce SQL Server specific syntax and keywords to your query. There is nothing in your query that you can't do in HQL, or using Hibernate's Criteria API.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic