本文整理汇总了Java中org.hibernate.dialect.SQLServerDialect类的典型用法代码示例。如果您正苦于以下问题:Java SQLServerDialect类的具体用法?Java SQLServerDialect怎么用?Java SQLServerDialect使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SQLServerDialect类属于org.hibernate.dialect包,在下文中一共展示了SQLServerDialect类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: determineDatabaseDialectClass
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
/**
* Determine the Hibernate database dialect class for the given target database.
* @param database the target database
* @return the Hibernate database dialect class, or {@code null} if none found
*/
@SuppressWarnings("deprecation")
protected Class<?> determineDatabaseDialectClass(Database database) {
switch (database) {
case DB2: return DB2Dialect.class;
case DERBY: return DerbyDialect.class; // DerbyDialect deprecated in 4.x
case H2: return H2Dialect.class;
case HSQL: return HSQLDialect.class;
case INFORMIX: return InformixDialect.class;
case MYSQL: return MySQLDialect.class;
case ORACLE: return Oracle9iDialect.class;
case POSTGRESQL: return PostgreSQLDialect.class; // PostgreSQLDialect deprecated in 4.x
case SQL_SERVER: return SQLServerDialect.class;
case SYBASE: return org.hibernate.dialect.SybaseDialect.class; // SybaseDialect deprecated in 3.6 but not 4.x
default: return null;
}
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:22,代码来源:HibernateJpaVendorAdapter.java
示例2: hibernateDatabaseDialectClass
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
private static Class<?> hibernateDatabaseDialectClass(DatabasePlatform database) {
switch (database) {
case DB2:
return DB2Dialect.class;
case DB2_AS400:
return DB2400Dialect.class;
case DERBY:
return DerbyTenSevenDialect.class;
case H2:
return H2Dialect.class;
case HSQL:
return HSQLDialect.class;
case INFORMIX:
return InformixDialect.class;
case MYSQL:
return MySQL5Dialect.class;
case ORACLE:
return Oracle10gDialect.class;
case POSTGRESQL:
return PostgreSQL82Dialect.class;
case SQL_SERVER:
return SQLServerDialect.class;
case MARIADB:
return MySQL5Dialect.class;
case HANA:
return HANARowStoreDialect.class;
case SQLITE:
case NONE:
default:
break;
}
return null;
}
开发者ID:holon-platform,项目名称:holon-datastore-jpa,代码行数:34,代码来源:EntityManagerFactoryConfigurator.java
示例3: getHibernateDialect
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
private Class<? extends Dialect> getHibernateDialect(final PersistenceUnitContext context) {
final ConnectionDialect dialect = context.getConnectionDialect();
switch (dialect) {
case MSSQLSERVER:
return SQLServerDialect.class;
case MYSQL:
return MySQL5InnoDBDialect.class;
case POSTGRESQL:
return PostgreSQL9Dialect.class;
case ORACLE:
return Oracle10gDialect.class;
case H2:
return H2Dialect.class;
default:
throw UnknownArgumentException.newInstance(ConnectionDialect.class, dialect);
}
}
开发者ID:subes,项目名称:invesdwin-context-persistence,代码行数:18,代码来源:HibernateDialectSpecificDelegate.java
示例4: determineDatabaseDialectClass
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
/**
* Determine the Hibernate database dialect class for the given target database.
* @param database the target database
* @return the Hibernate database dialect class, or {@code null} if none found
*/
protected Class determineDatabaseDialectClass(Database database) {
switch (database) {
case DB2: return DB2Dialect.class;
case DERBY: return DerbyDialect.class;
case H2: return H2Dialect.class;
case HSQL: return HSQLDialect.class;
case INFORMIX: return InformixDialect.class;
case MYSQL: return MySQLDialect.class;
case ORACLE: return Oracle9iDialect.class;
case POSTGRESQL: return PostgreSQLDialect.class;
case SQL_SERVER: return SQLServerDialect.class;
case SYBASE: return SybaseDialect.class;
default: return null;
}
}
开发者ID:deathspeeder,项目名称:class-guard,代码行数:21,代码来源:HibernateJpaVendorAdapter.java
示例5: getEngineDecorator
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
public static EngineDecorator getEngineDecorator(String dialect) throws ClassNotFoundException {
Class<?> dialectClass = Class.forName(dialect);
if (MySQLDialect.class.isAssignableFrom(dialectClass)) {
return new MySQLDecorator();
} else if (PostgreSQL81Dialect.class.isAssignableFrom(dialectClass)) {
return new PostgreSQLDecorator();
} else if (Oracle8iDialect.class.isAssignableFrom(dialectClass)) {
return new OracleDecorator();
} else if (SQLServerDialect.class.isAssignableFrom(dialectClass)) {
return new SQLServerDecorator();
}
return new NoOpDecorator();
}
开发者ID:Devskiller,项目名称:jpa2ddl,代码行数:15,代码来源:EngineDecorator.java
示例6: dialectAdapter
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
/**
* Adapt "default.sql" to every supported database
*/
public static String dialectAdapter(InputStream is, String dialect) {
StringBuilder sb = new StringBuilder();
BufferedReader br = null;
String line;
try {
br = new BufferedReader(new InputStreamReader(is));
if (Oracle10gDialect.class.getCanonicalName().equals(dialect)) {
log.info("Generation SQL for Oracle10gDialect...");
while ((line = br.readLine()) != null) {
sb.append(oracleAdapter(line)).append("\n");
}
} else if (SQLServerDialect.class.getCanonicalName().equals(dialect)) {
log.info("Generation SQL for SQLServerDialect...");
while ((line = br.readLine()) != null) {
sb.append(sqlServerAdapter(line)).append("\n");
}
} else {
log.info("Generation SQL for GeneralDialect...");
while ((line = br.readLine()) != null) {
sb.append(line).append("\n");
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
IOUtils.closeQuietly(br);
IOUtils.closeQuietly(is);
}
return sb.toString().trim();
}
开发者ID:openkm,项目名称:document-management-system,代码行数:40,代码来源:DatabaseDialectAdapter.java
示例7: HibernateDatabaseConfigurationFactory
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
public HibernateDatabaseConfigurationFactory() {
builtInConfigurations = new HashMap<String, DatabaseConfiguration>();
builtInConfigurations.put(SQLServerDialect.class.getName(),
new MSSQLServerDatabaseConfiguration());
builtInConfigurations.put(Oracle10gDialect.class.getName(),
new OracleDatabaseConfiguration());
builtInConfigurations.put(PostgreSQLDialect.class.getName(),
new PostgreSQLDatabaseConfiguration());
}
开发者ID:Communote,项目名称:communote-server,代码行数:10,代码来源:HibernateDatabaseConfigurationFactory.java
示例8: testStr
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
public void testStr() {
Session session = openSession();
Transaction txn = session.beginTransaction();
Animal an = new Animal();
an.setBodyWeight(123.45f);
session.persist(an);
String str = (String) session.createQuery("select str(an.bodyWeight) from Animal an where str(an.bodyWeight) like '123%' or str(an.bodyWeight) like '1.23%'").uniqueResult();
if ( getDialect() instanceof DB2Dialect ) {
assertTrue( str.startsWith("1.234") );
}
else if ( getDialect() instanceof SQLServerDialect ) {
// no assertion as SQLServer always returns nulls here; even trying directly against the
// database, it seems to have problems with str() in the where clause...
}
else {
assertTrue( str.startsWith("123.4") );
}
if ( ! ( getDialect() instanceof SybaseDialect ) ) {
// In TransactSQL (the variant spoken by Sybase and SQLServer), the str() function
// is explicitly intended for numeric values only...
String dateStr1 = (String) session.createQuery("select str(current_date) from Animal").uniqueResult();
String dateStr2 = (String) session.createQuery("select str(year(current_date))||'-'||str(month(current_date))||'-'||str(day(current_date)) from Animal").uniqueResult();
System.out.println(dateStr1 + '=' + dateStr2);
if ( ! ( getDialect() instanceof Oracle9Dialect || getDialect() instanceof Oracle8iDialect ) ) { //Oracle renders the name of the month :(
String[] dp1 = StringHelper.split("-", dateStr1);
String[] dp2 = StringHelper.split("-", dateStr2);
for (int i=0; i<3; i++) {
if ( dp1[i].startsWith( "0" ) ) {
dp1[i] = dp1[i].substring( 1 );
}
assertEquals( dp1[i], dp2[i] );
}
}
}
session.delete(an);
txn.commit();
session.close();
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:39,代码来源:ASTParserLoadingTest.java
示例9: determineDatabaseDialectClass
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
/**
* Determine the Hibernate database dialect class for the given target database.
* @param database the target database
* @return the Hibernate database dialect class, or <code>null<code> if none found
*/
protected Class determineDatabaseDialectClass(Database database) {
switch (database) {
case DB2: return DB2Dialect.class;
case HSQL: return HSQLDialect.class;
case INFORMIX: return InformixDialect.class;
case MYSQL: return MySQLDialect.class;
case ORACLE: return Oracle9iDialect.class;
case POSTGRESQL: return PostgreSQLDialect.class;
case SQL_SERVER: return SQLServerDialect.class;
case SYBASE: return SybaseASE15Dialect.class;
default: return null;
}
}
开发者ID:aapotts,项目名称:kuali_rice,代码行数:19,代码来源:DevHibernateJpaVendorAdapter.java
示例10: executeDataMigration
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
@Override
protected void executeDataMigration(final HibernateMigrationHelper helper, final MigrationResult result,
Session session)
{
final Dialect dialect = helper.getFactory().getDialect();
if( dialect instanceof SQLServerDialect )
{
session.doWork(new Work()
{
@Override
public void execute(Connection connection) throws SQLException
{
final DatabaseMetaData metaData = connection.getMetaData();
final String defaultCatalog = helper.getDefaultCatalog();
final String defaultSchema = helper.getDefaultSchema();
final ResultSet tableSet = metaData.getTables(defaultCatalog, defaultSchema, null,
new String[]{"TABLE"});
final List<String> tableNames = Lists.newArrayList();
try
{
while( tableSet.next() )
{
tableNames.add(tableSet.getString("TABLE_NAME"));
}
}
finally
{
tableSet.close();
}
for( String tableName : tableNames )
{
final List<ColMeta> ntextCols = Lists.newArrayList();
final ResultSet columnSet = metaData.getColumns(defaultCatalog, defaultSchema, tableName, null);
try
{
while( columnSet.next() )
{
final String colName = columnSet.getString("COLUMN_NAME");
final String colDbType = columnSet.getString("TYPE_NAME");
if( colDbType.equalsIgnoreCase("ntext") )
{
LOGGER.info("ntext column found: " + tableName + "." + colName);
final int nullable = columnSet.getInt("NULLABLE");
final ColMeta colMeta = new ColMeta();
colMeta.nullable = (nullable != DatabaseMetaData.columnNoNulls);
colMeta.name = colName;
ntextCols.add(colMeta);
}
}
}
finally
{
columnSet.close();
}
for( ColMeta ntextCol : ntextCols )
{
final String sql = "ALTER TABLE " + Table.qualify(defaultCatalog, defaultSchema, tableName)
+ " ALTER COLUMN " + ntextCol.name + " nvarchar(max)"
+ (ntextCol.nullable ? "" : " NOT") + " NULL";
final PreparedStatement s = connection.prepareStatement(sql);
s.execute();
}
// We don't seem to need to update
// http://stackoverflow.com/questions/4708463/converting-ntext-to-nvcharmaxmax-getting-around-size-limitation
result.incrementStatus();
}
}
});
}
}
开发者ID:equella,项目名称:Equella,代码行数:78,代码来源:ConvertNtextDatabaseMigration.java
示例11: executeDataMigration
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
@Override
protected void executeDataMigration(final HibernateMigrationHelper helper, final MigrationResult result,
Session session)
{
final Dialect dialect = helper.getFactory().getDialect();
if( dialect instanceof SQLServerDialect )
{
session.doWork(new Work()
{
@Override
public void execute(Connection connection) throws SQLException
{
final DatabaseMetaData metaData = connection.getMetaData();
final String defaultCatalog = helper.getDefaultCatalog();
final String defaultSchema = helper.getDefaultSchema();
final ResultSet tableSet = metaData.getTables(defaultCatalog, defaultSchema, null,
new String[]{"TABLE"});
final List<String> tableNames = Lists.newArrayList();
try
{
while( tableSet.next() )
{
tableNames.add(tableSet.getString("TABLE_NAME"));
}
}
finally
{
tableSet.close();
}
for( String tableName : tableNames )
{
final List<ColMeta> ntextCols = Lists.newArrayList();
final ResultSet columnSet = metaData.getColumns(defaultCatalog, defaultSchema, tableName, null);
try
{
while( columnSet.next() )
{
final String colName = columnSet.getString("COLUMN_NAME");
final String colDbType = columnSet.getString("TYPE_NAME");
if( colDbType.equalsIgnoreCase("varchar") || colDbType.equalsIgnoreCase("text") )
{
LOGGER.info("varchar column found: " + tableName + "." + colName);
final int nullable = columnSet.getInt("NULLABLE");
final ColMeta colMeta = new ColMeta();
colMeta.size = columnSet.getInt("COLUMN_SIZE");
colMeta.nullable = (nullable != DatabaseMetaData.columnNoNulls);
colMeta.name = colName;
ntextCols.add(colMeta);
}
}
}
finally
{
columnSet.close();
}
for( ColMeta ntextCol : ntextCols )
{
String sizeStr = ntextCol.size == Integer.MAX_VALUE ? "max"
: Integer.toString(ntextCol.size);
final String sql = "ALTER TABLE " + Table.qualify(defaultCatalog, defaultSchema, tableName)
+ " ALTER COLUMN " + ntextCol.name + " nvarchar(" + sizeStr + ")"
+ (ntextCol.nullable ? "" : " NOT") + " NULL";
final PreparedStatement s = connection.prepareStatement(sql);
s.execute();
}
result.incrementStatus();
}
}
});
}
}
开发者ID:equella,项目名称:Equella,代码行数:79,代码来源:ConvertVarcharDatabaseMigration.java
示例12: addDialects
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
private void addDialects(StrategySelectorImpl strategySelector) {
addDialect( strategySelector, Cache71Dialect.class );
addDialect( strategySelector, CUBRIDDialect.class );
addDialect( strategySelector, DB2Dialect.class );
addDialect( strategySelector, DB2390Dialect.class );
addDialect( strategySelector, DB2400Dialect.class );
addDialect( strategySelector, DerbyTenFiveDialect.class );
addDialect( strategySelector, DerbyTenSixDialect.class );
addDialect( strategySelector, DerbyTenSevenDialect.class );
addDialect( strategySelector, FirebirdDialect.class );
addDialect( strategySelector, FrontBaseDialect.class );
addDialect( strategySelector, H2Dialect.class );
addDialect( strategySelector, HSQLDialect.class );
addDialect( strategySelector, InformixDialect.class );
addDialect( strategySelector, IngresDialect.class );
addDialect( strategySelector, Ingres9Dialect.class );
addDialect( strategySelector, Ingres10Dialect.class );
addDialect( strategySelector, InterbaseDialect.class );
addDialect( strategySelector, JDataStoreDialect.class );
addDialect( strategySelector, MckoiDialect.class );
addDialect( strategySelector, MimerSQLDialect.class );
addDialect( strategySelector, MySQL5Dialect.class );
addDialect( strategySelector, MySQL5InnoDBDialect.class );
addDialect( strategySelector, MySQL5Dialect.class );
addDialect( strategySelector, MySQL5InnoDBDialect.class );
addDialect( strategySelector, Oracle8iDialect.class );
addDialect( strategySelector, Oracle9iDialect.class );
addDialect( strategySelector, Oracle10gDialect.class );
addDialect( strategySelector, PointbaseDialect.class );
addDialect( strategySelector, PostgresPlusDialect.class );
addDialect( strategySelector, PostgreSQL81Dialect.class );
addDialect( strategySelector, PostgreSQL82Dialect.class );
addDialect( strategySelector, PostgreSQL9Dialect.class );
addDialect( strategySelector, ProgressDialect.class );
addDialect( strategySelector, SAPDBDialect.class );
addDialect( strategySelector, SQLServerDialect.class );
addDialect( strategySelector, SQLServer2005Dialect.class );
addDialect( strategySelector, SQLServer2008Dialect.class );
addDialect( strategySelector, Sybase11Dialect.class );
addDialect( strategySelector, SybaseAnywhereDialect.class );
addDialect( strategySelector, SybaseASE15Dialect.class );
addDialect( strategySelector, SybaseASE157Dialect.class );
addDialect( strategySelector, TeradataDialect.class );
addDialect( strategySelector, TimesTenDialect.class );
}
开发者ID:lamsfoundation,项目名称:lams,代码行数:46,代码来源:StrategySelectorBuilder.java
示例13: createHibernateDialect
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
@Override
protected Dialect createHibernateDialect() {
return new SQLServerDialect();
}
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:5,代码来源:SqlServer2008DbDialect.java
示例14: isSqlServer
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
public boolean isSqlServer() {
return getHibernateDialect() instanceof SQLServerDialect;
}
开发者ID:passion1014,项目名称:metaworks_framework,代码行数:4,代码来源:DialectHelper.java
示例15: testStaleVersionedInstanceFoundOnLock
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
public void testStaleVersionedInstanceFoundOnLock() {
if ( ! readCommittedIsolationMaintained( "repeatable read tests" ) ) {
return;
}
if ( getDialect().doesReadCommittedCauseWritersToBlockReaders()) {
reportSkip( "lock blocking", "stale versioned instance" );
return;
}
String check = "EJB3 Specification";
Session s1 = getSessions().openSession();
Transaction t1 = s1.beginTransaction();
Item item = new Item( check );
s1.save( item );
t1.commit();
s1.close();
Long itemId = item.getId();
long initialVersion = item.getVersion();
// Now, open a new Session and re-load the item...
s1 = getSessions().openSession();
t1 = s1.beginTransaction();
item = ( Item ) s1.get( Item.class, itemId );
// now that the item is associated with the persistence-context of that session,
// open a new session and modify it "behind the back" of the first session
Session s2 = getSessions().openSession();
Transaction t2 = s2.beginTransaction();
Item item2 = ( Item ) s2.get( Item.class, itemId );
item2.setName( "EJB3 Persistence Spec" );
t2.commit();
s2.close();
// at this point, s1 now contains stale data, so acquire a READ lock
// and make sure we get the already associated state (i.e., the old
// name and the old version)
s1.lock( item, LockMode.READ );
item2 = ( Item ) s1.get( Item.class, itemId );
assertTrue( item == item2 );
assertEquals( "encountered non-repeatable read", check, item2.getName() );
assertEquals( "encountered non-repeatable read", initialVersion, item2.getVersion() );
// attempt to acquire an UPGRADE lock; this should fail
try {
s1.lock( item, LockMode.UPGRADE );
fail( "expected UPGRADE lock failure" );
}
catch( StaleObjectStateException expected ) {
// this is the expected behavior
}
catch( SQLGrammarException t ) {
if ( getDialect() instanceof SQLServerDialect ) {
// sql-server (using snapshot isolation) reports this as a grammar exception /:)
//
// not to mention that it seems to "lose track" of the transaction in this scenario...
t1.rollback();
t1 = s1.beginTransaction();
}
else {
throw t;
}
}
t1.commit();
s1.close();
// clean up
s1 = getSessions().openSession();
t1 = s1.beginTransaction();
s1.createQuery( "delete Item" ).executeUpdate();
t1.commit();
s1.close();
}
开发者ID:cacheonix,项目名称:cacheonix-core,代码行数:74,代码来源:RepeatableReadTest.java
示例16: JTDSDatabasePlatform
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
public JTDSDatabasePlatform() {
super(new SQLServerDialect(), "jdbc:jtds:sqlserver://<server>[:<port>][/<database>][;instance=<instance>]");
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:4,代码来源:JTDSDatabasePlatform.java
示例17: MSSqlServerDatabasePlatform
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
public MSSqlServerDatabasePlatform() {
super(new SQLServerDialect(), "jdbc:sqlserver://<host>[:<port>];database=<databaseName>");
}
开发者ID:ManyDesigns,项目名称:Portofino,代码行数:4,代码来源:MSSqlServerDatabasePlatform.java
示例18: testLoadSaveRepository
import org.hibernate.dialect.SQLServerDialect; //导入依赖的package包/类
public void testLoadSaveRepository() throws Exception {
Connection theConnection = createConnection();
Class theHibernateDialect = SQLServerDialect.class;
String theModelResource = "/de/erdesignerng/test/io/repository/examplemodel.mxm";
String theNewFile = RepositioryHelper.performRepositorySaveAndLoad(theModelResource, theHibernateDialect,
theConnection);
String theOriginalFile = IOUtils.toString(getClass().getResourceAsStream(theModelResource));
assertTrue(compareStrings(theOriginalFile, theNewFile));
}
开发者ID:mirkosertic,项目名称:ERDesignerNG,代码行数:16,代码来源:RepositoryIOTest.java
注:本文中的org.hibernate.dialect.SQLServerDialect类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论