File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Object Relational Mapping and the fly likes Hibernate 3 not able to recognize the Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Hibernate 3 not able to recognize the "ON" word in sql" Watch "Hibernate 3 not able to recognize the "ON" word in sql" New topic
Author

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

Kartik Talasu
Ranch Hand

Joined: Aug 21, 2009
Posts: 98
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

Joined: Apr 14, 2004
Posts: 10336

How are you running this bit of SQL? Are you running it as a SQL query?


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Kartik Talasu
Ranch Hand

Joined: Aug 21, 2009
Posts: 98
in MSSQL console am running as query but where as in hibernate its giving error telling "Invalid token ON".
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Yes, what I mean is which Hibernate method are you using to run this bit of SQL.
Kartik Talasu
Ranch Hand

Joined: Aug 21, 2009
Posts: 98
This is the way i had used



Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Hibernate 3 not able to recognize the "ON" word in sql