SQLServerDialectpublic class SQLServerDialect extends SybaseDialect A dialect for Microsoft SQL Server 2000 and 2005 |
Constructors Summary |
---|
public SQLServerDialect()
registerColumnType( Types.VARBINARY, "image" );
registerColumnType( Types.VARBINARY, 8000, "varbinary($l)" );
registerFunction( "second", new SQLFunctionTemplate(Hibernate.INTEGER, "datepart(second, ?1)") );
registerFunction( "minute", new SQLFunctionTemplate(Hibernate.INTEGER, "datepart(minute, ?1)") );
registerFunction( "hour", new SQLFunctionTemplate(Hibernate.INTEGER, "datepart(hour, ?1)") );
registerFunction( "locate", new StandardSQLFunction("charindex", Hibernate.INTEGER) );
registerFunction( "extract", new SQLFunctionTemplate( Hibernate.INTEGER, "datepart(?1, ?3)" ) );
registerFunction( "mod", new SQLFunctionTemplate( Hibernate.INTEGER, "?1 % ?2" ) );
registerFunction( "bit_length", new SQLFunctionTemplate( Hibernate.INTEGER, "datalength(?1) * 8" ) );
registerFunction( "trim", new AnsiTrimEmulationFunction() );
registerKeyword("top");
|
Methods Summary |
---|
public java.lang.String | appendIdentitySelectToInsert(java.lang.String insertSQL)Use insert table(...) values(...) select SCOPE_IDENTITY()
return insertSQL + " select scope_identity()";
| public java.lang.String | appendLockHint(org.hibernate.LockMode mode, java.lang.String tableName)
if ( mode.greaterThan( LockMode.READ ) ) {
// does this need holdlock also? : return tableName + " with (updlock, rowlock, holdlock)";
return tableName + " with (updlock, rowlock)";
}
else {
return tableName;
}
| public boolean | areStringComparisonsCaseInsensitive()
return true;
| public char | closeQuote()
return ']";
| public boolean | doesReadCommittedCauseWritersToBlockReaders()
return false; // here assume SQLServer2005 using snapshot isolation, which does not have this problem
| public boolean | doesRepeatableReadCauseReadersToBlockWriters()
return false; // here assume SQLServer2005 using snapshot isolation, which does not have this problem
| static int | getAfterSelectInsertPoint(java.lang.String sql)
int selectIndex = sql.toLowerCase().indexOf( "select" );
final int selectDistinctIndex = sql.toLowerCase().indexOf( "select distinct" );
return selectIndex + ( selectDistinctIndex == selectIndex ? 15 : 6 );
| public java.lang.String | getCurrentTimestampSelectString()
return "select current_timestamp";
| public java.lang.String | getLimitString(java.lang.String querySelect, int offset, int limit)
if ( offset > 0 ) {
throw new UnsupportedOperationException( "sql server has no offset" );
}
return new StringBuffer( querySelect.length()+8 )
.append(querySelect)
.insert( getAfterSelectInsertPoint(querySelect), " top " + limit )
.toString();
| public java.lang.String | getNoColumnsInsertString()
return "default values";
| public java.lang.String | getSelectGUIDString()
return "select newid()";
| public char | openQuote()
return '[";
| public boolean | supportsCircularCascadeDeleteConstraints()
// SQL Server (at least up through 2005) does not support defining
// cascade delete constraints which can circel back to the mutating
// table
return false;
| public boolean | supportsLimit()
return true;
| public boolean | supportsLimitOffset()
return false;
| public boolean | supportsLobValueChangePropogation()
// note: at least my local SQL Server 2005 Express shows this not working...
return false;
| public boolean | supportsResultSetPositionQueryMethodsOnForwardOnlyCursor()
return false;
| public boolean | supportsVariableLimit()
return false;
| public boolean | useMaxForLimit()
return true;
|
|