📄 dialect.java
字号:
return null;
}
/**
* The keyword used to insert a row without specifying any column values.
* This is not possible on some databases.
*/
public String getNoColumnsInsertString() {
return "values ( )";
}
/**
* Generate the appropriate select statement to to retreive the next value
* of a sequence, if sequences are supported.
* <p/>
* This should be a "stand alone" select statement.
*
* @param sequenceName the name of the sequence
* @return String The "nextval" select string.
* @throws MappingException if no sequences
*/
public String getSequenceNextValString(String sequenceName) throws MappingException {
throw new MappingException( "Dialect does not support sequences" );
}
/**
* Generate the select expression fragment that will retreive the next
* value of a sequence, if sequences are supported.
* <p/>
* This differs from {@link #getSequenceNextValString(String)} in that this
* should return an expression usable within another select statement.
*
* @param sequenceName the name of the sequence
* @return String
* @throws MappingException if no sequences
*/
public String getSelectSequenceNextValString(String sequenceName) throws MappingException {
throw new MappingException( "Dialect does not support sequences" );
}
/**
* The syntax used to create a sequence, if sequences are supported.
*
* @param sequenceName the name of the sequence
* @return String
* @throws MappingException if no sequences
*/
protected String getCreateSequenceString(String sequenceName) throws MappingException {
throw new MappingException( "Dialect does not support sequences" );
}
/**
* The multiline script used to create a sequence, if sequences are supported.
*
* @param sequenceName the name of the sequence
* @return String[]
* @throws MappingException if no sequences
*/
public String[] getCreateSequenceStrings(String sequenceName) throws MappingException {
return new String[]{getCreateSequenceString( sequenceName )};
}
/**
* The syntax used to drop a sequence, if sequences are supported.
*
* @param sequenceName the name of the sequence
* @return String
* @throws MappingException if no sequences
*/
protected String getDropSequenceString(String sequenceName) throws MappingException {
throw new MappingException( "Dialect does not support sequences" );
}
/**
* The multiline script used to drop a sequence, if sequences are supported.
*
* @param sequenceName the name of the sequence
* @return String[]
* @throws MappingException if no sequences
*/
public String[] getDropSequenceStrings(String sequenceName) throws MappingException {
return new String[]{getDropSequenceString( sequenceName )};
}
/**
* A query used to find all sequences
*
* @see org.hibernate.tool.hbm2ddl.SchemaUpdate
*/
public String getQuerySequencesString() {
return null;
}
/**
* Get the <tt>Dialect</tt> specified by the current <tt>System</tt> properties.
*
* @return Dialect
* @throws HibernateException
*/
public static Dialect getDialect() throws HibernateException {
String dialectName = Environment.getProperties().getProperty( Environment.DIALECT );
if ( dialectName == null ) throw new HibernateException( "The dialect was not set. Set the property hibernate.dialect." );
try {
return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance();
}
catch ( ClassNotFoundException cnfe ) {
throw new HibernateException( "Dialect class not found: " + dialectName );
}
catch ( Exception e ) {
throw new HibernateException( "Could not instantiate dialect class", e );
}
}
/**
* Get the <tt>Dialect</tt> specified by the given properties or system properties.
*
* @param props
* @return Dialect
* @throws HibernateException
*/
public static Dialect getDialect(Properties props) throws HibernateException {
String dialectName = props.getProperty( Environment.DIALECT );
if ( dialectName == null ) return getDialect();
try {
return ( Dialect ) ReflectHelper.classForName( dialectName ).newInstance();
}
catch ( ClassNotFoundException cnfe ) {
throw new HibernateException( "Dialect class not found: " + dialectName );
}
catch ( Exception e ) {
throw new HibernateException( "Could not instantiate dialect class", e );
}
}
/**
* Retrieve a set of default Hibernate properties for this database.
*
* @return a set of Hibernate properties
*/
public final Properties getDefaultProperties() {
return properties;
}
/**
* Completely optional cascading drop clause
*
* @return String
*/
public String getCascadeConstraintsString() {
return "";
}
/**
* Create an <tt>OuterJoinGenerator</tt> for this dialect.
*
* @return OuterJoinGenerator
*/
public JoinFragment createOuterJoinFragment() {
return new ANSIJoinFragment();
}
/**
* Create a <tt>CaseFragment</tt> for this dialect.
*
* @return OuterJoinGenerator
*/
public CaseFragment createCaseFragment() {
return new ANSICaseFragment();
}
/**
* The name of the SQL function that transforms a string to
* lowercase
*
* @return String
*/
public String getLowercaseFunction() {
return "lower";
}
/**
* Does this <tt>Dialect</tt> have some kind of <tt>LIMIT</tt> syntax?
*/
public boolean supportsLimit() {
return false;
}
/**
* Does this dialect support an offset?
*/
public boolean supportsLimitOffset() {
return supportsLimit();
}
/**
* Add a <tt>LIMIT</tt> clause to the given SQL <tt>SELECT</tt>
*
* @return the modified SQL
*/
public String getLimitString(String querySelect, boolean hasOffset) {
throw new UnsupportedOperationException( "paged queries not supported" );
}
public String getLimitString(String querySelect, int offset, int limit) {
return getLimitString( querySelect, offset>0 );
}
public boolean supportsVariableLimit() {
return supportsLimit();
}
/**
* Does the <tt>LIMIT</tt> clause specify arguments in the "reverse" order
* limit, offset instead of offset, limit?
*
* @return true if the correct order is limit, offset
*/
public boolean bindLimitParametersInReverseOrder() {
return false;
}
/**
* Does the <tt>LIMIT</tt> clause come at the start of the
* <tt>SELECT</tt> statement, rather than at the end?
*
* @return true if limit parameters should come before other parameters
*/
public boolean bindLimitParametersFirst() {
return false;
}
/**
* Does the <tt>LIMIT</tt> clause take a "maximum" row number instead
* of a total number of returned rows?
*/
public boolean useMaxForLimit() {
return false;
}
/**
* The opening quote for a quoted identifier
*/
public char openQuote() {
return '"';
}
/**
* The closing quote for a quoted identifier
*/
public char closeQuote() {
return '"';
}
/**
* SQL functions as defined in general. The results of this
* method should be integrated with the specialisation's data.
*/
public final Map getFunctions() {
return sqlFunctions;
}
public boolean supportsIfExistsBeforeTableName() {
return false;
}
public boolean supportsIfExistsAfterTableName() {
return false;
}
/**
* Does this dialect support column-level check constraints?
*/
public boolean supportsColumnCheck() {
return true;
}
/**
* Does this dialect support table-level check constraints?
*/
public boolean supportsTableCheck() {
return true;
}
/**
* Whether this dialect have an Identity clause added to the data type or a
* completely seperate identity data type
*
* @return boolean
*/
public boolean hasDataTypeInIdentityColumn() {
return true;
}
public boolean supportsCascadeDelete() {
return true;
}
/**
* Method <code>appendLockHint</code> appends according to the given
* lock mode a lock hint behind the given table name, if this dialect
* needs this. MS SQL Server for example doesn't support the
* standard "<code>select ... for update</code>" syntax and use a
* special "<code>select ... from TABLE as ALIAS with (updlock, rowlock)
* where ...</code>" syntax instead.
*
* @param tableName name of table to append lock hint
* @return String
* <p/>
* author <a href="http://sourceforge.net/users/heschulz">Helge Schulz</a>
*/
public String appendLockHint(LockMode mode, String tableName) {
return tableName;
}
public Class getNativeIdentifierGeneratorClass() {
if ( supportsIdentityColumns() ) {
return IdentityGenerator.class;
}
else if ( supportsSequences() ) {
return SequenceGenerator.class;
}
else {
return TableHiLoGenerator.class;
}
}
public String getSelectGUIDString() {
throw new UnsupportedOperationException( "dialect does not support GUIDs" );
}
public boolean supportsOuterJoinForUpdate() {
return true;
}
public String getSelectClauseNullString(int sqlType) {
return "null";
}
public boolean supportsNotNullUnique() {
return true;
}
/**
* 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.
* <p/>
* 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.
*
* @return The Dialect's preferred SQLExceptionConverter.
*/
public SQLExceptionConverter buildSQLExceptionConverter() {
// The default SQLExceptionConverter for all dialects is based on SQLState
// since SQLErrorCode is extremely vendor-specific. Specific Dialects
// may override to return whatever is most appropriate for that vendor.
return new SQLStateConverter( getViolatedConstraintNameExtracter() );
}
private static final ViolatedConstraintNameExtracter EXTRACTER = new ViolatedConstraintNameExtracter() {
public String extractConstraintName(SQLException sqle) {
return null;
}
};
public ViolatedConstraintNameExtracter getViolatedConstraintNameExtracter() {
return EXTRACTER;
}
public final String quote(String column) {
if ( column.charAt( 0 ) == '`' ) {
return openQuote() + column.substring( 1, column.length() - 1 ) + closeQuote();
}
else {
return column;
}
}
public boolean hasSelfReferentialForeignKeyBug() {
return false;
}
public boolean useInputStreamToInsertBlob() {
return true;
}
public int registerResultSetOutParameter(CallableStatement statement, int col) throws SQLException {
throw new UnsupportedOperationException(
getClass().getName() +
" does not support resultsets via stored procedures"
);
}
public ResultSet getResultSet(CallableStatement ps) throws SQLException {
throw new UnsupportedOperationException(
getClass().getName() +
" does not support resultsets via stored procedures"
);
}
public boolean supportsUnionAll() {
return false;
}
public boolean supportsCommentOn() {
return false;
}
public String getTableComment(String comment) {
return "";
}
public String getColumnComment(String comment) {
return "";
}
public String transformSelectString(String select) {
return select;
}
public boolean supportsTemporaryTables() {
return false;
}
public String generateTemporaryTableName(String baseTableName) {
return "HT_" + baseTableName;
}
public String getCreateTemporaryTableString() {
return "create table";
}
public boolean performTemporaryTableDDLInIsolation() {
return false;
}
public String getCreateTemporaryTablePostfix() {
return "";
}
public boolean dropTemporaryTableAfterUse() {
return true;
}
public String getForUpdateString(LockMode lockMode) {
if ( lockMode==LockMode.UPGRADE ) {
return getForUpdateString();
}
else if ( lockMode==LockMode.UPGRADE_NOWAIT ) {
return getForUpdateNowaitString();
}
else {
return "";
}
}
public int getMaxAliasLength() {
return 10;
}
public boolean supportsCurrentTimestampSelection() {
return false;
}
public String getCurrentTimestampSelectString() {
throw new UnsupportedOperationException( "Database not known to define a current timestamp function" );
}
public boolean isCurrentTimestampSelectStringCallable() {
throw new UnsupportedOperationException( "Database not known to define a current timestamp function" );
}
/**
* The SQL value that the JDBC driver maps boolean values to
*/
public String toBooleanValueString(boolean bool) {
return bool ? "1" : "0";
}
/**
* Does this dialect support parameters within the select clause of
* INSERT ... SELECT ... statements?
*
* @return True if this is supported; false otherwise.
*/
public boolean supportsParametersInInsertSelect() {
return true;
}
/**
* The name of the database-specific SQL function for retrieving the
* current timestamp.
*
* @return The function name.
*/
public String getCurrentTimestampSQLFunctionName() {
// the standard SQL function name is current_timestamp...
return "current_timestamp";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -