Help coderanch get a
new server
by contributing to the fundraiser
  • 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

how can i make sql queries database independent using Hibernate?

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
how can i make sql queries database independent using Hibernate?

iam storing date as string in database........for date conversion each database will follow some predefined methods

like wise there will be some other methods which serves the same purpose w.r.t database

how do i handle such cases in hibernate?
 
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
Which part are you worried about not being database independent?

Hibernate abstracts out the database thought the hibernate.cfg.xml file. So, you code Hibernate once, and you just change the entries in the xml file when you switch databases. Hibernate uses HQL, Hibernate Query Language, as opposed to SQL, so even there, you are buffered against a specific database SQL call.

>>for date conversion each database will follow some predefined methods

Well, this tends to be more the application/business logic problem. If every database is different, and it needs different logic, well, each database will need to be coded differently. But that's not a Hibernate or SQL issue, that's just an issue of the architect or application that it was designed in such a way that standard SQL, which has worked pretty good for almost every other application in the world, just doesn't cut it. Ok, that's perhaps a little over the top sarcastic, but I hope you see my point.

Perhaps a more mature question on my point would be to ask what this database specific task is? If we can factor that out, perhaps we can really get to the heart of the problem.

-Cameron McKenzie
 
Your buns are mine! But you can have this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/t/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic