Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

how can i make sql queries database independent using Hibernate?

 
Ranch Hand
Posts: 261
  • Mark post as helpful
  • send pies
  • 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: 5000
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • 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
 
I'm thinking about a new battle cry. Maybe "Not in the face! Not in the face!" Any thoughts tiny ad?
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic