⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialect.java

📁 hibernate-distribution-3.3.1.GA-dist.zip源码
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
	protected void registerKeyword(String word) {		sqlKeywords.add(word);	}	public Set getKeywords() {		return sqlKeywords;	}	// native identifier generatiion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	/**	 * The class (which implements {@link org.hibernate.id.IdentifierGenerator})	 * which acts as this dialects native generation strategy.	 * <p/>	 * Comes into play whenever the user specifies the native generator.	 *	 * @return The native generator class.	 */	public Class getNativeIdentifierGeneratorClass() {		if ( supportsIdentityColumns() ) {			return IdentityGenerator.class;		}		else if ( supportsSequences() ) {			return SequenceGenerator.class;		}		else {			return TableHiLoGenerator.class;		}	}	// IDENTITY support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	/**	 * Does this dialect support identity column key generation?	 *	 * @return True if IDENTITY columns are supported; false otherwise.	 */	public boolean supportsIdentityColumns() {		return false;	}	/**	 * Does the dialect support some form of inserting and selecting	 * the generated IDENTITY value all in the same statement.	 *	 * @return True if the dialect supports selecting the just	 * generated IDENTITY in the insert statement.	 */	public boolean supportsInsertSelectIdentity() {		return false;	}	/**	 * 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;	}	/**	 * Provided we {@link #supportsInsertSelectIdentity}, then attch the	 * "select identity" clause to the  insert statement.	 *  <p/>	 * Note, if {@link #supportsInsertSelectIdentity} == false then	 * the insert-string should be returned without modification.	 *	 * @param insertString The insert command	 * @return The insert command with any necessary identity select	 * clause attached.	 */	public String appendIdentitySelectToInsert(String insertString) {		return insertString;	}	/**	 * Get the select command to use to retrieve the last generated IDENTITY	 * value for a particuar table	 *	 * @param table The table into which the insert was done	 * @param column The PK column.	 * @param type The {@link java.sql.Types} type code.	 * @return The appropriate select command	 * @throws MappingException If IDENTITY generation is not supported.	 */	public String getIdentitySelectString(String table, String column, int type) throws MappingException {		return getIdentitySelectString();	}	/**	 * Get the select command to use to retrieve the last generated IDENTITY	 * value.	 *	 * @return The appropriate select command	 * @throws MappingException If IDENTITY generation is not supported.	 */	protected String getIdentitySelectString() throws MappingException {		throw new MappingException( "Dialect does not support identity key generation" );	}	/**	 * The syntax used during DDL to define a column as being an IDENTITY of	 * a particular type.	 *	 * @param type The {@link java.sql.Types} type code.	 * @return The appropriate DDL fragment.	 * @throws MappingException If IDENTITY generation is not supported.	 */	public String getIdentityColumnString(int type) throws MappingException {		return getIdentityColumnString();	}	/**	 * The syntax used during DDL to define a column as being an IDENTITY.	 *	 * @return The appropriate DDL fragment.	 * @throws MappingException If IDENTITY generation is not supported.	 */	protected String getIdentityColumnString() throws MappingException {		throw new MappingException( "Dialect does not support identity key generation" );	}	/**	 * The keyword used to insert a generated value into an identity column (or null).	 * Need if the dialect does not support inserts that specify no column values.	 *	 * @return The appropriate keyword.	 */	public String getIdentityInsertString() {		return null;	}	// SEQUENCE support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	/**	 * Does this dialect support sequences?	 *	 * @return True if sequences supported; false otherwise.	 */	public boolean supportsSequences() {		return false;	}	/**	 * Does this dialect support "pooled" sequences.  Not aware of a better	 * name for this.  Essentially can we specify the initial and increment values?	 *	 * @return True if such "pooled" sequences are supported; false otherwise.	 * @see #getCreateSequenceStrings(String, int, int)	 * @see #getCreateSequenceString(String, int, int)	 */	public boolean supportsPooledSequences() {		return false;	}	/**	 * Generate the appropriate select statement to to retreive the next value	 * of a sequence.	 * <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 sequences are not supported.	 */	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 as part of another (typically DML) statement.	 * <p/>	 * This differs from {@link #getSequenceNextValString(String)} in that this	 * should return an expression usable within another statement.	 *	 * @param sequenceName the name of the sequence	 * @return The "nextval" fragment.	 * @throws MappingException If sequences are not supported.	 */	public String getSelectSequenceNextValString(String sequenceName) throws MappingException {		throw new MappingException( "Dialect does not support sequences" );	}	/**	 * The multiline script used to create a sequence.	 *	 * @param sequenceName The name of the sequence	 * @return The sequence creation commands	 * @throws MappingException If sequences are not supported.	 * @deprecated Use {@link #getCreateSequenceString(String, int, int)} instead	 */	public String[] getCreateSequenceStrings(String sequenceName) throws MappingException {		return new String[] { getCreateSequenceString( sequenceName ) };	}	/**	 * An optional multi-line form for databases which {@link #supportsPooledSequences()}.	 *	 * @param sequenceName The name of the sequence	 * @param initialValue The initial value to apply to 'create sequence' statement	 * @param incrementSize The increment value to apply to 'create sequence' statement	 * @return The sequence creation commands	 * @throws MappingException If sequences are not supported.	 */	public String[] getCreateSequenceStrings(String sequenceName, int initialValue, int incrementSize) throws MappingException {		return new String[] { getCreateSequenceString( sequenceName, initialValue, incrementSize ) };	}	/**	 * Typically dialects which support sequences can create a sequence	 * with a single command.  This is convenience form of	 * {@link #getCreateSequenceStrings} to help facilitate that.	 * <p/>	 * Dialects which support sequences and can create a sequence in a	 * single command need *only* override this method.  Dialects	 * which support sequences but require multiple commands to create	 * a sequence should instead override {@link #getCreateSequenceStrings}.	 *	 * @param sequenceName The name of the sequence	 * @return The sequence creation command	 * @throws MappingException If sequences are not supported.	 */	protected String getCreateSequenceString(String sequenceName) throws MappingException {		throw new MappingException( "Dialect does not support sequences" );	}	/**	 * Overloaded form of {@link #getCreateSequenceString(String)}, additionally	 * taking the initial value and increment size to be applied to the sequence	 * definition.	 * </p>	 * The default definition is to suffix {@link #getCreateSequenceString(String)}	 * with the string: " start with {initialValue} increment by {incrementSize}" where	 * {initialValue} and {incrementSize} are replacement placeholders.  Generally	 * dialects should only need to override this method if different key phrases	 * are used to apply the allocation information.	 *	 * @param sequenceName The name of the sequence	 * @param initialValue The initial value to apply to 'create sequence' statement	 * @param incrementSize The increment value to apply to 'create sequence' statement	 * @return The sequence creation command	 * @throws MappingException If sequences are not supported.	 */	protected String getCreateSequenceString(String sequenceName, int initialValue, int incrementSize) throws MappingException {		if ( supportsPooledSequences() ) {			return getCreateSequenceString( sequenceName ) + " start with " + initialValue + " increment by " + incrementSize;		}		throw new MappingException( "Dialect does not support pooled sequences" );	}	/**	 * The multiline script used to drop a sequence.	 *	 * @param sequenceName The name of the sequence	 * @return The sequence drop commands	 * @throws MappingException If sequences are not supported.	 */	public String[] getDropSequenceStrings(String sequenceName) throws MappingException {		return new String[]{getDropSequenceString( sequenceName )};	}	/**	 * Typically dialects which support sequences can drop a sequence	 * with a single command.  This is convenience form of	 * {@link #getDropSequenceStrings} to help facilitate that.	 * <p/>	 * Dialects which support sequences and can drop a sequence in a	 * single command need *only* override this method.  Dialects	 * which support sequences but require multiple commands to drop	 * a sequence should instead override {@link #getDropSequenceStrings}.	 *	 * @param sequenceName The name of the sequence	 * @return The sequence drop commands	 * @throws MappingException If sequences are not supported.	 */	protected String getDropSequenceString(String sequenceName) throws MappingException {		throw new MappingException( "Dialect does not support sequences" );	}	/**	 * Get the select command used retrieve the names of all sequences.	 *	 * @return The select command; or null if sequences are not supported.	 * @see org.hibernate.tool.hbm2ddl.SchemaUpdate	 */	public String getQuerySequencesString() {		return null;	}	// GUID support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	/**	 * Get the command used to select a GUID from the underlying database.	 * <p/>	 * Optional operation.	 *	 * @return The appropriate command.	 */	public String getSelectGUIDString() {		throw new UnsupportedOperationException( "dialect does not support GUIDs" );	}	// limit/offset support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	/**	 * Does this dialect support some form of limiting query results	 * via a SQL clause?	 *	 * @return True if this dialect supports some form of LIMIT.	 */	public boolean supportsLimit() {		return false;	}	/**	 * Does this dialect's LIMIT support (if any) additionally	 * support specifying an offset?	 *	 * @return True if the dialect supports an offset within the limit support.	 */	public boolean supportsLimitOffset() {		return supportsLimit();	}	/**	 * Does this dialect support bind variables (i.e., prepared statememnt	 * parameters) for its limit/offset?	 *	 * @return True if bind variables can be used; false otherwise.	 */	public boolean supportsVariableLimit() {		return supportsLimit();	}	/**	 * ANSI SQL defines the LIMIT clause to be in the form LIMIT offset, limit.	 * Does this dialect require us to bind the parameters in reverse order?	 *	 * @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?	 * <p/>	 * This is easiest understood via an example.  Consider you have a table	 * with 20 rows, but you only want to retrieve rows number 11 through 20.	 * Generally, a limit with offset would say that the offset = 11 and the	 * limit = 10 (we only want 10 rows at a time); this is specifying the	 * total number of returned rows.  Some dialects require that we instead	 * specify offset = 11 and limit = 20, where 20 is the "last" row we want	 * relative to offset (i.e. total number of rows = 20 - 11 = 9)	 * <p/>	 * So essentially, is limit relative from offset?  Or is limit absolute?	 *	 * @return True if limit is relative from offset; false otherwise.	 */	public boolean useMaxForLimit() {		return false;	}	/**	 * Given a limit and an offset, apply the limit clause to the query.	 *	 * @param query The query to which to apply the limit.	 * @param offset The offset of the limit	 * @param limit The limit of the limit ;)	 * @return The modified query statement with the limit applied.	 */	public String getLimitString(String query, int offset, int limit) {		return getLimitString( query, offset > 0 );	}	/**	 * Apply s limit clause to the query.	 * <p/>	 * Typically dialects utilize {@link #supportsVariableLimit() variable}	 * limit caluses when they support limits.  Thus, when building the	 * select command we do not actually need to know the limit or the offest	 * since we will just be using placeholders.	 * <p/>	 * Here we do still pass along whether or not an offset was specified	 * so that dialects not supporting offsets can generate proper exceptions.	 * In general, dialects will override one or the other of this method and	 * {@link #getLimitString(String, int, int)}.	 *	 * @param query The query to which to apply the limit.	 * @param hasOffset Is the query requesting an offset?	 * @return the modified SQL	 */	protected String getLimitString(String query, boolean hasOffset) {		throw new UnsupportedOperationException( "paged queries not supported" );	}	// lock acquisition support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~	/**	 * Get a strategy instance which knows how to acquire a database-level lock	 * of the specified mode for this dialect.	 *	 * @param lockable The persister for the entity to be locked.	 * @param lockMode The type of lock to be acquired.	 * @return The appropriate locking strategy.	 * @since 3.2	 */	public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {		return new SelectLockingStrategy( lockable, lockMode );	}	/**	 * Given a lock mode, determine the appropriate for update fragment to use.	 *	 * @param lockMode The lock mode to apply.	 * @return The appropriate for update fragment.	 */	public String getForUpdateString(LockMode lockMode) {		if ( lockMode==LockMode.UPGRADE ) {			return getForUpdateString();		}		else if ( lockMode==LockMode.UPGRADE_NOWAIT ) {			return getForUpdateNowaitString();		}		else if ( lockMode==LockMode.FORCE ) {			return getForUpdateNowaitString();		}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -