📄 dialect.java
字号:
else { return ""; } } /** * Get the string to append to SELECT statements to acquire locks * for this dialect. * * @return The appropriate <tt>FOR UPDATE</tt> clause string. */ public String getForUpdateString() { return " for update"; } /** * Is <tt>FOR UPDATE OF</tt> syntax supported? * * @return True if the database supports <tt>FOR UPDATE OF</tt> syntax; * false otherwise. */ public boolean forUpdateOfColumns() { // by default we report no support return false; } /** * Does this dialect support <tt>FOR UPDATE</tt> in conjunction with * outer joined rows? * * @return True if outer joined rows can be locked via <tt>FOR UPDATE</tt>. */ public boolean supportsOuterJoinForUpdate() { return true; } /** * Get the <tt>FOR UPDATE OF column_list</tt> fragment appropriate for this * dialect given the aliases of the columns to be write locked. * * @param aliases The columns to be write locked. * @return The appropriate <tt>FOR UPDATE OF column_list</tt> clause string. */ public String getForUpdateString(String aliases) { // by default we simply return the getForUpdateString() result since // the default is to say no support for "FOR UPDATE OF ..." return getForUpdateString(); } /** * Retrieves the <tt>FOR UPDATE NOWAIT</tt> syntax specific to this dialect. * * @return The appropriate <tt>FOR UPDATE NOWAIT</tt> clause string. */ public String getForUpdateNowaitString() { // by default we report no support for NOWAIT lock semantics return getForUpdateString(); } /** * Get the <tt>FOR UPDATE OF column_list NOWAIT</tt> fragment appropriate * for this dialect given the aliases of the columns to be write locked. * * @param aliases The columns to be write locked. * @return The appropriate <tt>FOR UPDATE colunm_list NOWAIT</tt> clause string. */ public String getForUpdateNowaitString(String aliases) { return getForUpdateString( aliases ); } /** * Some dialects support an alternative means to <tt>SELECT FOR UPDATE</tt>, * whereby a "lock hint" is appends to the table name in the from clause. * <p/> * contributed by <a href="http://sourceforge.net/users/heschulz">Helge Schulz</a> * * @param mode The lock mode to apply * @param tableName The name of the table to which to apply the lock hint. * @return The table with any required lock hints. */ public String appendLockHint(LockMode mode, String tableName) { return tableName; } /** * Modifies the given SQL by applying the appropriate updates for the specified * lock modes and key columns. * <p/> * The behavior here is that of an ANSI SQL <tt>SELECT FOR UPDATE</tt>. This * method is really intended to allow dialects which do not support * <tt>SELECT FOR UPDATE</tt> to achieve this in their own fashion. * * @param sql the SQL string to modify * @param aliasedLockModes a map of lock modes indexed by aliased table names. * @param keyColumnNames a map of key columns indexed by aliased table names. * @return the modified SQL string. */ public String applyLocksToSql(String sql, Map aliasedLockModes, Map keyColumnNames) { return sql + new ForUpdateFragment( this, aliasedLockModes, keyColumnNames ).toFragmentString(); } // table support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Command used to create a table. * * @return The command used to create a table. */ public String getCreateTableString() { return "create table"; } /** * Slight variation on {@link #getCreateTableString}. Here, we have the * command used to create a table when there is no primary key and * duplicate rows are expected. * <p/> * Most databases do not care about the distinction; originally added for * Teradata support which does care. * * @return The command used to create a multiset table. */ public String getCreateMultisetTableString() { return getCreateTableString(); } // temporary table support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Does this dialect support temporary tables? * * @return True if temp tables are supported; false otherwise. */ public boolean supportsTemporaryTables() { return false; } /** * Generate a temporary table name given the bas table. * * @param baseTableName The table name from which to base the temp table name. * @return The generated temp table name. */ public String generateTemporaryTableName(String baseTableName) { return "HT_" + baseTableName; } /** * Command used to create a temporary table. * * @return The command used to create a temporary table. */ public String getCreateTemporaryTableString() { return "create table"; } /** * Get any fragments needing to be postfixed to the command for * temporary table creation. * * @return Any required postfix. */ public String getCreateTemporaryTablePostfix() { return ""; } /** * Does the dialect require that temporary table DDL statements occur in * isolation from other statements? This would be the case if the creation * would cause any current transaction to get committed implicitly. * <p/> * JDBC defines a standard way to query for this information via the * {@link java.sql.DatabaseMetaData#dataDefinitionCausesTransactionCommit()} * method. However, that does not distinguish between temporary table * DDL and other forms of DDL; MySQL, for example, reports DDL causing a * transaction commit via its driver, even though that is not the case for * temporary table DDL. * <p/> * Possible return values and their meanings:<ul> * <li>{@link Boolean#TRUE} - Unequivocally, perform the temporary table DDL * in isolation.</li> * <li>{@link Boolean#FALSE} - Unequivocally, do <b>not</b> perform the * temporary table DDL in isolation.</li> * <li><i>null</i> - defer to the JDBC driver response in regards to * {@link java.sql.DatabaseMetaData#dataDefinitionCausesTransactionCommit()}</li> * </ul> * * @return see the result matrix above. */ public Boolean performTemporaryTableDDLInIsolation() { return null; } /** * Do we need to drop the temporary table after use? * * @return True if the table should be dropped. */ public boolean dropTemporaryTableAfterUse() { return true; } // callable statement support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Registers an OUT parameter which will be returing a * {@link java.sql.ResultSet}. How this is accomplished varies greatly * from DB to DB, hence its inclusion (along with {@link #getResultSet}) here. * * @param statement The callable statement. * @param position The bind position at which to register the OUT param. * @return The number of (contiguous) bind positions used. * @throws SQLException Indicates problems registering the OUT param. */ public int registerResultSetOutParameter(CallableStatement statement, int position) throws SQLException { throw new UnsupportedOperationException( getClass().getName() + " does not support resultsets via stored procedures" ); } /** * Given a callable statement previously processed by {@link #registerResultSetOutParameter}, * extract the {@link java.sql.ResultSet} from the OUT parameter. * * @param statement The callable statement. * @return The extracted result set. * @throws SQLException Indicates problems extracting the result set. */ public ResultSet getResultSet(CallableStatement statement) throws SQLException { throw new UnsupportedOperationException( getClass().getName() + " does not support resultsets via stored procedures" ); } // current timestamp support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Does this dialect support a way to retrieve the database's current * timestamp value? * * @return True if the current timestamp can be retrieved; false otherwise. */ public boolean supportsCurrentTimestampSelection() { return false; } /** * Should the value returned by {@link #getCurrentTimestampSelectString} * be treated as callable. Typically this indicates that JDBC escape * sytnax is being used... * * @return True if the {@link #getCurrentTimestampSelectString} return * is callable; false otherwise. */ public boolean isCurrentTimestampSelectStringCallable() { throw new UnsupportedOperationException( "Database not known to define a current timestamp function" ); } /** * Retrieve the command used to retrieve the current timestammp from the * database. * * @return The command. */ public String getCurrentTimestampSelectString() { throw new UnsupportedOperationException( "Database not known to define a current timestamp function" ); } /** * 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"; } // SQLException support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * 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; } // union subclass support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Given a {@link java.sql.Types} type code, determine an appropriate * null value to use in a select clause. * <p/> * One thing to consider here is that certain databases might * require proper casting for the nulls here since the select here * will be part of a UNION/UNION ALL. * * @param sqlType The {@link java.sql.Types} type code. * @return The appropriate select clause value fragment. */ public String getSelectClauseNullString(int sqlType) { return "null"; } /** * Does this dialect support UNION ALL, which is generally a faster * variant of UNION? * * @return True if UNION ALL is supported; false otherwise. */ public boolean supportsUnionAll() { return false; } // miscellaneous support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * Create a {@link org.hibernate.sql.JoinFragment} strategy responsible * for handling this dialect's variations in how joins are handled. * * @return This dialect's {@link org.hibernate.sql.JoinFragment} strategy. */ public JoinFragment createOuterJoinFragment() { return new ANSIJoinFragment(); } /** * Create a {@link org.hibernate.sql.CaseFragment} strategy responsible * for handling this dialect's variations in how CASE statements are * handled. * * @return This dialect's {@link org.hibernate.sql.CaseFragment} strategy. */ public CaseFragment createCaseFragment() { return new ANSICaseFragment(); } /** * The fragment used to insert a row without specifying any column values. * This is not possible on some databases. * * @return The appropriate empty values clause. */ public String getNoColumnsInsertString() { return "values ( )"; } /** * The name of the SQL function that transforms a string to * lowercase * * @return The dialect-specific lowercase function. */ public String getLowercaseFunction() { return "lower"; } /** * Meant as a means for end users to affect the select strings being sent * to the database and perhaps manipulate them in some fashion. * <p/> * The recommend approach is to instead use * {@link org.hibernate.Interceptor#onPrepareStatement(String)}. * * @param select The select command * @return The mutated select command, or the same as was passed in. */ public String transformSelectString(String select) { return select; } /** * What is the maximum length Hibernate can use for generated aliases? * * @return The maximum length. */ public int getMaxAliasLength() { return 10; } /** * The SQL literal value to which this database maps boolean values. * * @param bool The boolean value * @return The appropriate SQL literal. */ public String toBooleanValueString(boolean bool) { return bool ? "1" : "0"; } // identifier quoting support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /** * The character specific to this dialect used to begin a quoted identifier. * * @return The dialect's specific open quote character. */ public char openQuote() { return '"'; } /** * The character specific to this dialect used to close a quoted identifier. * * @return The dialect's specific close quote character. */ public char closeQuote() { return '"'; } /** * Apply dialect-specific quoting. * <p/> * By default, the incoming value is checked to see if its first character
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -