• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Q 4 C. Bauer & G. King (4): Hibernate SQL rule base?

 
Gian Franco
blacksmith
Ranch Hand
Posts: 979
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear authors,

My impression is that Hibernate must
have made a compromise between the
formulation of SQL statements for
different database vendors,
additionally I guess it has a rule
base with which it determines how
to best translate a request for
data into an SQL query (joins,
unions, etc. etc.)

Can a programmer intervene on these
decisions in order to guide the
formulation of SQL?

Or am I misinterpreting the whole thing?

Cheers,

Gian Franco Casula
 
Christian Bauer
author
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The SQL abstraction layer in Hibernate is called "Dialects". That means you can easily write a new Dialect subclass that implements vendor-specific behavior. Hibernate comes bundled with Dialects for more than 20 DBMS. If that is not sufficient, you can execute some native SQL queries (or get a JDBC connection) in Hibernate2 and completely customize any SQL Hibernate executes in Hibernate3.
 
somkiat puisungnoen
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
3.5.1. SQL Dialects
You should always set the hibernate.dialect property to the correct net.sf.hibernate.dialect.Dialect subclass for your database. This is not strictly essential unless you wish to use native or sequence primary key generation or pessimistic locking (with, eg. Session.lock() or Query.setLockMode()). However, if you specify a dialect, Hibernate will use sensible defaults for some of the other properties listed above, saving you the effort of specifying them manually.

Table 3.4. Hibernate SQL Dialects (hibernate.dialect)

RDBMS Dialect
DB2 net.sf.hibernate.dialect.DB2Dialect
DB2 AS/400 net.sf.hibernate.dialect.DB2400Dialect
DB2 OS390 net.sf.hibernate.dialect.DB2390Dialect
PostgreSQL net.sf.hibernate.dialect.PostgreSQLDialect
MySQL net.sf.hibernate.dialect.MySQLDialect
Oracle (any version) net.sf.hibernate.dialect.OracleDialect
Oracle 9/10g net.sf.hibernate.dialect.Oracle9Dialect
Sybase net.sf.hibernate.dialect.SybaseDialect
Sybase Anywhere net.sf.hibernate.dialect.SybaseAnywhereDialect
Microsoft SQL Server net.sf.hibernate.dialect.SQLServerDialect
SAP DB net.sf.hibernate.dialect.SAPDBDialect
Informix net.sf.hibernate.dialect.InformixDialect
HypersonicSQL net.sf.hibernate.dialect.HSQLDialect
Ingres net.sf.hibernate.dialect.IngresDialect
Progress net.sf.hibernate.dialect.ProgressDialect
Mckoi SQL net.sf.hibernate.dialect.MckoiDialect
Interbase net.sf.hibernate.dialect.InterbaseDialect
Pointbase net.sf.hibernate.dialect.PointbaseDialect
FrontBase net.sf.hibernate.dialect.FrontbaseDialect
Firebird net.sf.hibernate.dialect.FirebirdDialect

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic