This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
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

purpose of dialects

 
Ravi Bansal
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


I have just started reading
Hibernate Made Easy by Cameron McKenzie
I am very much new to hibernate.. I just wanted to understand the purpose of dialects(which is actually a DB specific) that we specify in the configuration.? If its just to tell the hibernate framework that which type of DB (MySql, sybase, Oracle) we are specifying, then we specify this using the JDBC Driver class, then what purpose actually dialects serve?


 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for picking up a copy of my Hibernate book! I hope you enjoy it.

One reason we specify a dialect is just to set up various sensible default properties for the database. It just makes life easier. And, there are always subtle differences between databases. Here are four properties that have defaults provided for them when a dialect is set:

CLOSED_QUOTE, DEFAULT_BATCH_SIZE, NO_BATCH, QUOTE

There are also methods such as these, which might have different implementations depending on the database:

getCastTypeName(int code)
Get the name of the database type appropriate for casting operations (via the CAST() SQL function) for the given Types typecode.

getColumnComment(String comment)

getSelectGUIDString()
Get the command used to select a GUID from the underlying database.

supportsCascadeDelete()

supportsLobValueChangePropogation()
Does the dialect support propogating changes to LOB values back to the database?


Hibernate JavaDoc for the Dialect Class

Good luck with the book! There's some errata and a link to some source code at the bottom of this page where the comments begin:

Errata for Hiberante Made Easy - And Source Code

-Cameron McKenzie

 
Ravi Bansal
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Cameron,

Thanks for the reply........but again , i am still not much convinced........as dialects still seems to be very much DB specific(which can be conveyed to hibernate framework with just the JDBC driver).......Why cant framework set up the default properites looking at the driver class and determing which type of DB it is ?...or i can frame my question in a different way ......can a specific DB have different dialects specified .....for example , is it possible to specify some other dialect class than MySqlDialect for MySQL data base?

 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, your question is a good one. I'm not totally sure of the answer. I also hope you don't get too hung up on it. There are alot of other challenges ahead in your learning of Hibernate.

Let me just suggest this: for db2, I had five different drivers that I often switched between, and that was just for DB2 running on a Windows XP maching. I had the APP driver, the NET driver, the JDBC-ODBC bridge, an XA compliant driver and a non-XA compliant driver. And who knows when a new, improved driver might come out. Perhaps it's just too dangerous to parse the name of the driver being used, or to inspect the driver and come to an assumption.

That's just a supposition. The people that implemented Hiberante are much smarter and much better looking than me. I'm sure there was some very valid and simple reason. Perhaps it's one of the points I've supposed already.

Regards,

-Cameron McKenzie
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic