• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

what's the syntax differnece between hibernate hql and sql?

 
Ranch Hand
Posts: 229
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what's the syntax differnece between hibernate hql and sql? Is sql 100% native sql which means you should be able to paste the sql code into mysql query browser and it should work?
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup, if you paste SQL into the MySQL query browser, that should run. When I'm having trouble with my queries, I often take the SQL generated by Hibernate, stuff it into the MySQL query browser, and see what happens. Sometimes, fiddling with the SQL can help me see what I've done wrong in my HQL or Criteria queries.

HQL is Hibernate based, and Hiberante is based on Java Objects. So, I can have one Java object that maps to three database tables. Selecting * from that class would generate SQL that queries all three databases. So, in just that one scenario, you can see that the HQL and SQL would be very, very different.

In many applications, the database tables and Java objects mirror each other, so sometimes the SQL and HQL can look very, very similar. But don't let this lull you into thinking they are the same. They are two very different monsters.

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