Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is Hibernate is DB dependent or Independent?

 
Edward Durai
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Hibernate supports lot of databases. My Question is

1. Is Hibernate Works in all databases
2. And How this Hibernate Works for multiple database

for eg. in oracle integer data type is integer/number
and in mysql integer data type is int

Pls give me the explanation

Thanks
edward
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

1. Is Hibernate Works in all databases

No. But it works with all the big name databases. Have a read of the supported databases on the hibernate site.



2. And How this Hibernate Works for multiple database

Hibernate will work with a whole host of databases without any code changes, with the caveat that you don't implement any database specific stuff in your data access code, such as vendor-specific SQL, using the database to generate primary keys, calls to Stored Procedures etc. It does this by using a Dialect to talk to the database. All data manipulation happens to the object (often refered to as the Plain Old Java Object, or POJO), and Hibernate implements these changes to the data in the database by way of the Dialect. You just tell Hibernate (by way of a configuration file) which database you will be using and it handles all the details.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
with the caveat that you don't implement any database specific stuff in your data access code, such as vendor-specific SQL, using the database to generate primary keys, calls to Stored Procedures etc.


Yes, that is true, but don't think of it harshly. You can still use all these to boost your perfomance to your situation, and you can have all these "changes" in your XML, so that if you did change the database, you wouldn't have to change your code, but your Config and Mappings. Except when you do vendor-specific SQL using SQLQuery in your code, but there is a way to put vendor-specific SQL either as a named query, or if you want some in the Select portion of the SQL, then you can use a "Formula" property and put in the SQL for that part. Sorry going to far here.

Mark
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic