站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > Hibernate 2.1.8 正式版 API 英文文档

Dialect (Hibernate API Documentation) - Hibernate 2.1.8 正式版 API 英文文档


net.sf.hibernate.dialect
Class Dialect

java.lang.Object
  extended bynet.sf.hibernate.dialect.Dialect
Direct Known Subclasses:
DB2Dialect, FrontBaseDialect, GenericDialect, HSQLDialect, InformixDialect, IngresDialect, InterbaseDialect, MckoiDialect, MySQLDialect, Oracle9Dialect, PointbaseDialect, PostgreSQLDialect, ProgressDialect, SAPDBDialect, SybaseDialect, TimesTenDialect

public abstract class Dialect
extends Object

Represents a dialect of SQL implemented by a particular RDBMS. Subclasses implement Hibernate compatibility with different systems.

Subclasses should provide a public default constructor that register() a set of type mappings and default Hibernate properties.

Subclasses should be immutable.

Author:
Gavin King, David Channon

Field Summary
static String CLOSED_QUOTE
           
static String QUOTE
          Characters used for quoting SQL identifiers
 
Constructor Summary
protected Dialect()
           
 
Method Summary
 String appendIdentitySelectToInsert(String insertSQL)
          Generate SQL to get the identifier of an inserted row.
 boolean bindLimitParametersFirst()
          Does the LIMIT clause come at the start of the SELECT statement, rather than at the end?
 boolean bindLimitParametersInReverseOrder()
          Does the LIMIT clause specify arguments in the "reverse" order limit, offset instead of offset, limit?
 SQLExceptionConverter buildSQLExceptionConverter()
          Build an instance of the SQLExceptionConverter preferred by this dialect for converting SQLExceptions into Hibernate's JDBCException hierarchy.
 char closeQuote()
          The closing quote for a quoted identifier
 CaseFragment createCaseFragment()
          Create a CaseFragment for this dialect.
 JoinFragment createOuterJoinFragment()
          Create an OuterJoinGenerator for this dialect.
 boolean dropConstraints()
          Do we need to drop constraints before dropping tables in this dialect?
 String getAddColumnString()
          The syntax used to add a column to a table (optional).
 String getAddForeignKeyConstraintString(String constraintName, String[] foreignKey, String referencedTable, String[] primaryKey)
          The syntax used to add a foreign key constraint to a table.
 String getAddPrimaryKeyConstraintString(String constraintName)
          The syntax used to add a primary key constraint to a table.
 String getCascadeConstraintsString()
          Completely optional cascading drop clause
 String getCreateSequenceString(String sequenceName)
          The syntax used to create a sequence, if sequences are supported.
 Properties getDefaultProperties()
          Retrieve a set of default Hibernate properties for this database.
static Dialect getDialect()
          Get the Dialect specified by the current System properties.
static Dialect getDialect(Properties props)
          Get the Dialect specified by the given properties or system properties.
 String getDropForeignKeyString()
           
 String getDropSequenceString(String sequenceName)
          The syntax used to drop a sequence, if sequences are supported.
 Map getFunctions()
          SQL functions as defined in general.
 String getIdentityColumnString()
          The keyword used to specify an identity column, if identity column key generation is supported.
 String getIdentityInsertString()
          The keyword used to insert a generated value into an identity column (or null)
 String getIdentitySelectString()
          The syntax that returns the identity value of the last insert, if identity column key generation is supported.
 String getLimitString(String querySelect, boolean hasOffset)
          Add a LIMIT clause to the given SQL SELECT
 String getLimitString(String querySelect, boolean hasOffset, int limit)
           
 String getLowercaseFunction()
          The name of the SQL function that transforms a string to lowercase
 String getNoColumnsInsertString()
          The keyword used to insert a row without specifying any column values
 String getNullColumnString()
          The keyword used to specify a nullable column.
 String getQuerySequencesString()
          A query used to find all sequences
 char getSchemaSeparator()
          The separator between the schema/tablespace name and the table name.
 String getSequenceNextValString(String sequenceName)
          The syntax that fetches the next value of a sequence, if sequences are supported.
 String getTypeName(int code)
          Get the name of the database type associated with the given java.sql.Types typecode.
 String getTypeName(int code, int length)
          Get the name of the database type associated with the given java.sql.Types typecode.
 ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter()
           
 boolean hasAlterTable()
          Does this dialect support the ALTER TABLE syntax?
 boolean hasDataTypeInIdentityColumn()
          Whether this dialect have an Identity clause added to the data type or a completely seperate identity data type
 char openQuote()
          The opening quote for a quoted identifier
 boolean qualifyIndexName()
          Do we need to qualify index names with the schema name?
protected  void registerColumnType(int code, int capacity, String name)
          Subclasses register a typename for the given type code and maximum column length.
protected  void registerColumnType(int code, String name)
          Subclasses register a typename for the given type code.
protected  void registerFunction(String name, SQLFunction function)
           
 boolean supportsCheck()
          Does this dialect support check constraints?
 boolean supportsForUpdate()
          Does this dialect support the FOR UPDATE syntax?
 boolean supportsForUpdateNowait()
          Does this dialect support the Oracle-style FOR UPDATE NOWAIT syntax?
 boolean supportsForUpdateOf()
          Does this dialect support FOR UPDATE OF, allowing particular rows to be locked?
 boolean supportsIdentityColumns()
          Does this dialect support identity column key generation?
 boolean supportsIfExistsAfterTableName()
           
 boolean supportsIfExistsBeforeTableName()
           
 boolean supportsLimit()
          Does this Dialect have some kind of LIMIT syntax?
 boolean supportsLimitOffset()
          Does this dialect support an offset?
 boolean supportsSequences()
          Does this dialect support sequences?
 boolean supportsUnique()
          Does this dialect support the UNIQUE column syntax?
 boolean supportsUniqueConstraintInCreateAlterTable()
          Does this dialect support adding Unique constraints via create and alter table ?
 boolean supportsVariableLimit()
           
 String toString()
           
 boolean useMaxForLimit()
          Does the LIMIT clause take a "maximum" row number instead of a total number of returned rows?
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

QUOTE

public static final String QUOTE
Characters used for quoting SQL identifiers

See Also:
Constant Field Values

CLOSED_QUOTE

public static final String CLOSED_QUOTE
See Also:
Constant Field Values
Constructor Detail

Dialect

protected Dialect()
Method Detail

toString

public String toString()

getTypeName

public String getTypeName(int code)
                   throws HibernateException
Get the name of the database type associated with the given java.sql.Types typecode.

Parameters:
code - java.sql.Types typecode
Returns:
the database type name
Throws:
HibernateException

getTypeName

public String getTypeName(int code,
                          int length)
                   throws HibernateException
Get the name of the database type associated with the given java.sql.Types typecode.

Parameters:
code - java.sql.Types typecode
length - the length of the column
Returns:
the database type name
Throws:
HibernateException

registerFunction

protected void registerFunction(String name,
                                SQLFunction function)

registerColumnType

protected void registerColumnType(int code,
                                  int capacity,
                                  String name)
Subclasses register a typename for the given type code and maximum column length. $l in the type name with be replaced by the column length (if appropriate).

Parameters:
code - java.sql.Types typecode
capacity - maximum length of database type
name - the database type name

registerColumnType

protected void registerColumnType(int code,
                                  String name)
Subclasses register a typename for the given type code. $l in the type name with be replaced by the column length (if appropriate).

Parameters:
code - java.sql.Types typecode
name - the database type name

hasAlterTable

public boolean hasAlterTable()
Does this dialect support the ALTER TABLE syntax?

Returns:
boolean

dropConstraints

public boolean dropConstraints()
Do we need to drop constraints before dropping tables in this dialect?

Returns:
boolean

qualifyIndexName

public boolean qualifyIndexName()
Do we need to qualify index names with the schema name?

Returns:
boolean

supportsForUpdate

public boolean supportsForUpdate()
Does this dialect support the FOR UPDATE syntax?

Returns:
boolean

supportsForUpdateOf

public boolean supportsForUpdateOf()
Does this dialect support FOR UPDATE OF, allowing particular rows to be locked?


supportsForUpdateNowait

public boolean supportsForUpdateNowait()
Does this dialect support the Oracle-style FOR UPDATE NOWAIT syntax?

Returns:
boolean

supportsUnique

public boolean supportsUnique()
Does this dialect support the UNIQUE column syntax?

Returns:
boolean

supportsUniqueConstraintInCreateAlterTable

public boolean supportsUniqueConstraintInCreateAlterTable()
Does this dialect support adding Unique constraints via create and alter table ?

Returns:
boolean

getAddColumnString

public String getAddColumnString()
The syntax used to add a column to a table (optional).


getDropForeignKeyString

public String getDropForeignKeyString()

getAddForeignKeyConstraintString

public String getAddForeignKeyConstraintString(String constraintName,
                                               String[] foreignKey,
                                               String referencedTable,
                                               String[] primaryKey)
The syntax used to add a foreign key constraint to a table.

Returns:
String

getAddPrimaryKeyConstraintString

public String getAddPrimaryKeyConstraintString(String constraintName)
The syntax used to add a primary key constraint to a table.

Returns:
String

getNullColumnString

public String getNullColumnString()
The keyword used to specify a nullable column.

Returns:
String

supportsIdentityColumns

public boolean supportsIdentityColumns()
Does this dialect support identity column key generation?

Returns:
boolean

supportsSequences

public boolean supportsSequences()
Does this dialect support sequences?

Returns:
boolean

appendIdentitySelectToInsert

public String appendIdentitySelectToInsert(String insertSQL)
Generate SQL to get the identifier of an inserted row. If the returned value is not null, the caller will prepare a statement from it, set SQL parameters just as it would for insertSQL, and execute it as a query which is expected to return the identifier of the inserted row. If the returned value is null, the caller will execute insertSQL as an update and then execute getIdentitySelectString() as a query. The default implementation (in this class) returns null.

Parameters:
insertSQL - a parameterized SQL statement to insert a row into a table.
Returns:
a SQL statement that has the same effect as insertSQL and also gets the identifier of the inserted row. Return null if this dialect doesn't support this feature.

getIdentitySelectString

public String getIdentitySelectString()
                               throws MappingException
The syntax that returns the identity value of the last insert, if identity column key generation is supported.

Throws:
MappingException - if no native key generation

getIdentityColumnString

public String getIdentityColumnString()
                               throws MappingException
The keyword used to specify an identity column, if identity column key generation is supported.

Throws:
MappingException - if no native key generation

getIdentityInsertString

public String getIdentityInsertString()
The keyword used to insert a generated value into an identity column (or null)

Returns:
String

getNoColumnsInsertString

public String getNoColumnsInsertString()
The keyword used to insert a row without specifying any column values


getSequenceNextValString

public String getSequenceNextValString(String sequenceName)
                                throws MappingException
The syntax that fetches the next value of a sequence, if sequences are supported.

Parameters:
sequenceName - the name of the sequence
Returns:
String
Throws:
MappingException - if no sequences

getCreateSequenceString

public String getCreateSequenceString(String sequenceName)
                               throws MappingException
The syntax used to create a sequence, if sequences are supported.

Parameters:
sequenceName - the name of the sequence
Returns:
String
Throws:
MappingException - if no sequences

getDropSequenceString

public String getDropSequenceString(String sequenceName)
                             throws MappingException
The syntax used to drop a sequence, if sequences are supported.

Parameters:
sequenceName - the name of the sequence
Returns:
String
Throws:
MappingException - if no sequences

getQuerySequencesString

public String getQuerySequencesString()
A query used to find all sequences

See Also:
SchemaUpdate

getDialect

public static Dialect getDialect()
                          throws HibernateException
Get the Dialect specified by the current System properties.

Returns:
Dialect
Throws:
HibernateException

getDialect

public static Dialect getDialect(Properties props)
                          throws HibernateException
Get the Dialect specified by the given properties or system properties.

Parameters:
props -
Returns:
Dialect
Throws:
HibernateException

getDefaultProperties

public final Properties getDefaultProperties()
Retrieve a set of default Hibernate properties for this database.

Returns:
a set of Hibernate properties

getCascadeConstraintsString

public String getCascadeConstraintsString()
Completely optional cascading drop clause

Returns:
String

createOuterJoinFragment

public JoinFragment createOuterJoinFragment()
Create an OuterJoinGenerator for this dialect.

Returns:
OuterJoinGenerator

createCaseFragment

public CaseFragment createCaseFragment()
Create a CaseFragment for this dialect.

Returns:
OuterJoinGenerator

getLowercaseFunction

public String getLowercaseFunction()
The name of the SQL function that transforms a string to lowercase

Returns:
String

supportsLimit

public boolean supportsLimit()
Does this Dialect have some kind of LIMIT syntax?


supportsLimitOffset

public boolean supportsLimitOffset()
Does this dialect support an offset?


getLimitString

public String getLimitString(String querySelect,
                             boolean hasOffset)
Add a LIMIT clause to the given SQL SELECT

Returns:
the modified SQL

getLimitString

public String getLimitString(String querySelect,
                             boolean hasOffset,
                             int limit)

supportsVariableLimit

public boolean supportsVariableLimit()

bindLimitParametersInReverseOrder

public boolean bindLimitParametersInReverseOrder()
Does the LIMIT clause specify arguments in the "reverse" order limit, offset instead of offset, limit?

Returns:
true if the correct order is limit, offset

bindLimitParametersFirst

public boolean bindLimitParametersFirst()
Does the LIMIT clause come at the start of the SELECT statement, rather than at the end?

Returns:
true if limit parameters should come before other parameters

useMaxForLimit

public boolean useMaxForLimit()
Does the LIMIT clause take a "maximum" row number instead of a total number of returned rows?


openQuote

public char openQuote()
The opening quote for a quoted identifier


closeQuote

public char closeQuote()
The closing quote for a quoted identifier


getFunctions

public final Map getFunctions()
SQL functions as defined in general. The results of this method should be integrated with the specialisation's data.


supportsIfExistsBeforeTableName

public boolean supportsIfExistsBeforeTableName()

supportsIfExistsAfterTableName

public boolean supportsIfExistsAfterTableName()

getSchemaSeparator

public char getSchemaSeparator()
The separator between the schema/tablespace name and the table name.


supportsCheck

public boolean supportsCheck()
Does this dialect support check constraints?


hasDataTypeInIdentityColumn

public boolean hasDataTypeInIdentityColumn()
Whether this dialect have an Identity clause added to the data type or a completely seperate identity data type

Returns:
boolean

buildSQLExceptionConverter

public SQLExceptionConverter buildSQLExceptionConverter()
Build an instance of the SQLExceptionConverter preferred by this dialect for converting SQLExceptions into Hibernate's JDBCException hierarchy. The default Dialect implementation simply returns a converter based on X/Open SQLState codes. It is strongly recommended that specific Dialect implementations override this method, since interpretation of a SQL error is much more accurate when based on the ErrorCode rather than the SQLState. Unfortunately, the ErrorCode is a vendor- specific approach.

Returns:
The Dialect's preferred SQLExceptionConverter.

getViolatedConstraintNameExtracter

public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter()