當前位置: 首頁>>代碼示例>>Java>>正文


Java Dialect類代碼示例

本文整理匯總了Java中org.hibernate.dialect.Dialect的典型用法代碼示例。如果您正苦於以下問題:Java Dialect類的具體用法?Java Dialect怎麽用?Java Dialect使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Dialect類屬於org.hibernate.dialect包,在下文中一共展示了Dialect類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: resolveDialect

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
@Override
public final Dialect resolveDialect(DialectResolutionInfo info) {
	final String databaseName = info.getDatabaseName();
	final int databaseMajorVersion = info.getDatabaseMajorVersion();
	final int databaseMinorVersion = info.getDatabaseMinorVersion();

	if ( nameToMatch.equalsIgnoreCase( databaseName )
			&& ( majorVersionToMatch == NO_VERSION || majorVersionToMatch == databaseMajorVersion )
			&& ( minorVersionToMatch == NO_VERSION || majorVersionToMatch == databaseMinorVersion ) ) {
		try {
			return (Dialect) dialectClass.newInstance();
		}
		catch ( HibernateException e ) {
			// conceivable that the dialect ctor could throw HibernateExceptions, so don't re-wrap
			throw e;
		}
		catch ( Throwable t ) {
			throw new HibernateException(
					"Could not instantiate specified Dialect class [" + dialectClass.getName() + "]",
					t
			);
		}
	}

	return null;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:27,代碼來源:BasicDialectResolver.java

示例2: SchemaExport

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
/**
 * Create a schema exporter for the given Configuration, using the supplied connection for connectivity.
 *
 * @param configuration The configuration to use.
 * @param connection The JDBC connection to use.
 * @throws HibernateException Indicates problem preparing for schema export.
 */
public SchemaExport(Configuration configuration, Connection connection) throws HibernateException {
	this.connectionHelper = new SuppliedConnectionHelper( connection );

	this.sqlStatementLogger = new SqlStatementLogger( false, true );
	this.formatter = FormatStyle.DDL.getFormatter();
	this.sqlExceptionHelper = new SqlExceptionHelper();

	this.importFiles = ConfigurationHelper.getString(
			AvailableSettings.HBM2DDL_IMPORT_FILES,
			configuration.getProperties(),
			DEFAULT_IMPORT_FILE
	);

	final Dialect dialect = Dialect.getDialect( configuration.getProperties() );
	this.dropSQL = configuration.generateDropSchemaScript( dialect );
	this.createSQL = configuration.generateSchemaCreationScript( dialect );
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:SchemaExport.java

示例3: determineGeneratorTableName

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
/**
 * Determine the table name to use for the generator values.
 * <p/>
 * Called during {@link #configure configuration}.
 *
 * @see #getTableName()
 * @param params The params supplied in the generator config (plus some standard useful extras).
 * @param dialect The dialect in effect
 * @return The table name to use.
 */
protected String determineGeneratorTableName(Properties params, Dialect dialect) {
	String name = ConfigurationHelper.getString( TABLE_PARAM, params, DEF_TABLE );
	final boolean isGivenNameUnqualified = name.indexOf( '.' ) < 0;
	if ( isGivenNameUnqualified ) {
		final ObjectNameNormalizer normalizer = (ObjectNameNormalizer) params.get( IDENTIFIER_NORMALIZER );
		name = normalizer.normalizeIdentifierQuoting( name );
		// if the given name is un-qualified we may neen to qualify it
		final String schemaName = normalizer.normalizeIdentifierQuoting( params.getProperty( SCHEMA ) );
		final String catalogName = normalizer.normalizeIdentifierQuoting( params.getProperty( CATALOG ) );
		name = Table.qualify(
				dialect.quote( catalogName ),
				dialect.quote( schemaName ),
				dialect.quote( name)
		);
	}
	// if already qualified there is not much we can do in a portable manner so we pass it
	// through and assume the user has set up the name correctly.

	return name;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:31,代碼來源:TableGenerator.java

示例4: determineDialect

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
/**
 * Determine the appropriate Dialect to use given the connection.
 *
 * @param resolutionInfoSource Access to DialectResolutionInfo used to resolve the Dialect.
 *
 * @return The appropriate dialect instance.
 *
 * @throws HibernateException No connection given or no resolver could make
 * the determination from the given connection.
 */
private Dialect determineDialect(DialectResolutionInfoSource resolutionInfoSource) {
	if ( resolutionInfoSource == null ) {
		throw new HibernateException( "Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set" );
	}

	final DialectResolutionInfo info = resolutionInfoSource.getDialectResolutionInfo();
	final Dialect dialect = dialectResolver.resolveDialect( info );

	if ( dialect == null ) {
		throw new HibernateException(
				"Unable to determine Dialect to use [name=" + info.getDatabaseName() +
						", majorVersion=" + info.getDatabaseMajorVersion() +
						"]; user must register resolver or explicitly set 'hibernate.dialect'"
		);
	}

	return dialect;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:29,代碼來源:DialectFactoryImpl.java

示例5: getRenderText

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
@Override
@SuppressWarnings("unchecked")
public String getRenderText(SessionFactoryImplementor sessionFactory) {
	final Type type = expectedType == null
			? heuristicType
			: Number.class.isAssignableFrom( heuristicType.getReturnedClass() )
			? heuristicType
			: expectedType;
	try {
		final LiteralType literalType = (LiteralType) type;
		final Dialect dialect = factory.getDialect();
		return literalType.objectToSQLString( constantValue, dialect );
	}
	catch (Exception t) {
		throw new QueryException( QueryTranslator.ERROR_CANNOT_FORMAT_LITERAL + constantExpression, t );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:18,代碼來源:JavaConstantNode.java

示例6: before

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
@Before
public void before() throws Exception
{
       //see REPO-1524	
       Dialect dialect = (Dialect) applicationContext.getBean("dialect");
       assumeFalse(dialect instanceof AlfrescoOracle9Dialect);

	int port = getTestFixture().getJettyComponent().getPort();
	TestNetwork network = getTestFixture().getRandomNetwork();
   	Map<String, String> cmisParameters = new HashMap<String, String>();
   	cmisParameters.put(TestParameters.DEFAULT_RELATIONSHIP_TYPE, "R:cm:replaces");
   	clientContext = new OpenCMISClientContext(BindingType.ATOMPUB,
   			MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco", network.getId(), "public"),
   			"[email protected]" + network.getId(), "admin", cmisParameters, getTestFixture().getJettyComponent().getApplicationContext());
       overrideVersionableAspectProperties(getTestFixture().getJettyComponent().getApplicationContext());
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:17,代碼來源:TestPublicApiAtomPub10TCK.java

示例7: dropDatabaseSchema

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
/**
 * Execute schema drop script, determined by the Configuration object
 * used for creating the SessionFactory. A replacement for Hibernate's
 * SchemaExport class, to be invoked on application setup.
 * <p>Fetch the LocalSessionFactoryBean itself rather than the exposed
 * SessionFactory to be able to invoke this method, e.g. via
 * {@code LocalSessionFactoryBean lsfb = (LocalSessionFactoryBean) ctx.getBean("&mySessionFactory");}.
 * <p>Uses the SessionFactory that this bean generates for accessing a
 * JDBC connection to perform the script.
 * @throws org.springframework.dao.DataAccessException in case of script execution errors
 * @see org.hibernate.cfg.Configuration#generateDropSchemaScript
 * @see org.hibernate.tool.hbm2ddl.SchemaExport#drop
 */
public void dropDatabaseSchema() throws DataAccessException {
	logger.info("Dropping database schema for Hibernate SessionFactory");
	SessionFactory sessionFactory = getSessionFactory();
	final Dialect dialect = ((SessionFactoryImplementor) sessionFactory).getDialect();
	HibernateTemplate hibernateTemplate = new HibernateTemplate(sessionFactory);
	hibernateTemplate.execute(
		new HibernateCallback<Object>() {
			@Override
			public Object doInHibernate(Session session) throws HibernateException, SQLException {
				@SuppressWarnings("deprecation")
				Connection con = session.connection();
				String[] sql = getConfiguration().generateDropSchemaScript(dialect);
				executeSchemaScript(con, sql);
				return null;
			}
		}
	);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:32,代碼來源:LocalSessionFactoryBean.java

示例8: testGetProcessesMatchesIgnoreCaseNoResults

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
@Test
public void testGetProcessesMatchesIgnoreCaseNoResults()
{       
    Dialect dialect = (Dialect) applicationContext.getBean("dialect");
    if (dialect instanceof AlfrescoSQLServerDialect)
    {
        // REPO-1104: we do not run this test on MS SQL server because it will fail 
        // until the Activiti defect related to REPO-1104 will be fixed
        // this test could fail on other DBs where the LIKE operator behaves as case insensitive
        return;
    }
    CollectionWithPagingInfo<ProcessInfo> result = queryMatchesProcesses("test workflow api calls review and approve");

    assertNotNull(result);
    assertNotNull(result.getCollection());
    assertTrue(result.getTotalItems() == 0 );
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:18,代碼來源:ProcessesImplTest.java

示例9: buildSQLExceptionConverter

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
/**
 * Build a SQLExceptionConverter instance.
 * <p/>
 * First, looks for a {@link Environment#SQL_EXCEPTION_CONVERTER} property to see
 * if the configuration specified the class of a specific converter to use.  If this
 * property is set, attempt to construct an instance of that class.  If not set, or
 * if construction fails, the converter specific to the dialect will be used.
 *
 * @param dialect    The defined dialect.
 * @param properties The configuration properties.
 * @return An appropriate SQLExceptionConverter instance.
 * @throws HibernateException There was an error building the SQLExceptionConverter.
 */
public static SQLExceptionConverter buildSQLExceptionConverter(Dialect dialect, Properties properties) throws HibernateException {
	SQLExceptionConverter converter = null;

	String converterClassName = (String) properties.get( Environment.SQL_EXCEPTION_CONVERTER );
	if ( StringHelper.isNotEmpty( converterClassName ) ) {
		converter = constructConverter( converterClassName, dialect.getViolatedConstraintNameExtracter() );
	}

	if ( converter == null ) {
		LOG.trace( "Using dialect defined converter" );
		converter = dialect.buildSQLExceptionConverter();
	}

	if ( converter instanceof Configurable ) {
		try {
			( (Configurable) converter ).configure( properties );
		}
		catch (HibernateException e) {
			LOG.unableToConfigureSqlExceptionConverter( e );
			throw e;
		}
	}

	return converter;
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:39,代碼來源:SQLExceptionConverterFactory.java

示例10: before

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
@Before
public void before() throws Exception
{
       //see REPO-1524	
       Dialect dialect = (Dialect) applicationContext.getBean("dialect");
       assumeFalse(dialect instanceof AlfrescoOracle9Dialect); 

	int port = getTestFixture().getJettyComponent().getPort();
	TestNetwork network = getTestFixture().getRandomNetwork();
   	Map<String, String> cmisParameters = new HashMap<String, String>();
   	cmisParameters.put(TestParameters.DEFAULT_RELATIONSHIP_TYPE, "R:cm:replaces");
       cmisParameters.put(TestParameters.DEFAULT_SECONDARY_TYPE, "P:cm:author");
       cmisParameters.put(TestParameters.DEFAULT_ITEM_TYPE, "I:cm:cmobject");
   	clientContext = new OpenCMISClientContext(BindingType.ATOMPUB,
   			MessageFormat.format(CMIS_URL, "localhost", String.valueOf(port), "alfresco", network.getId(), "public"),
   			"[email protected]" + network.getId(), "admin", cmisParameters, getTestFixture().getJettyComponent().getApplicationContext());
       overrideVersionableAspectProperties(getTestFixture().getJettyComponent().getApplicationContext());
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:19,代碼來源:TestPublicApiAtomPub11TCK.java

示例11: sqlTemporaryTableCreateString

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
public String sqlTemporaryTableCreateString(Dialect dialect, Mapping mapping) throws HibernateException {
	StringBuilder buffer = new StringBuilder( dialect.getCreateTemporaryTableString() )
			.append( ' ' )
			.append( name )
			.append( " (" );
	Iterator itr = getColumnIterator();
	while ( itr.hasNext() ) {
		final Column column = (Column) itr.next();
		buffer.append( column.getQuotedName( dialect ) ).append( ' ' );
		buffer.append( column.getSqlType( dialect, mapping ) );
		if ( column.isNullable() ) {
			buffer.append( dialect.getNullColumnString() );
		}
		else {
			buffer.append( " not null" );
		}
		if ( itr.hasNext() ) {
			buffer.append( ", " );
		}
	}
	buffer.append( ") " );
	buffer.append( dialect.getCreateTemporaryTablePostfix() );
	return buffer.toString();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:25,代碼來源:Table.java

示例12: sqlConstraintStringAround

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
@Around("execution(java.lang.String org.hibernate.mapping.PrimaryKey.sqlConstraintString(..))")
public String sqlConstraintStringAround(ProceedingJoinPoint joinPoint) throws Throwable {
    Dialect dialect = (Dialect) joinPoint.getArgs()[0];
    if (!(dialect instanceof PhoenixDialect)) {
        // Nothing to deal with
        return (String) joinPoint.proceed();
    }

    String statement = (String) joinPoint.proceed();
    return "CONSTRAINT pk " + statement;
}
 
開發者ID:jruesga,項目名稱:phoenix-hibernate-dialect,代碼行數:12,代碼來源:MappingInterceptor.java

示例13: Delegate

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
public Delegate(PostInsertIdentityPersister persister, Dialect dialect, String sequenceName) {
	super( persister );
	this.dialect = dialect;
	this.sequenceNextValFragment = dialect.getSelectSequenceNextValString( sequenceName );
	this.keyColumns = getPersister().getRootTableKeyColumnNames();
	if ( keyColumns.length > 1 ) {
		throw new HibernateException( "sequence-identity generator cannot be used with with multi-column keys" );
	}
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:10,代碼來源:SequenceIdentityGenerator.java

示例14: setMaxStringLength

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
/**
 * @see #DEFAULT_MAX_STRING_LENGTH
 */
public static final void setMaxStringLength(int length, Dialect dialect)
{
    int max = (dialect instanceof AlfrescoMySQLClusterNDBDialect ? DEFAULT_MAX_STRING_LENGTH_NDB : DEFAULT_MAX_STRING_LENGTH);
    
    if (length < max)
    {
        throw new AlfrescoRuntimeException("The maximum string length must >= "+max+" characters.");
    }
    SchemaBootstrap.maxStringLength = length;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:14,代碼來源:SchemaBootstrap.java

示例15: getDialectResource

import org.hibernate.dialect.Dialect; //導入依賴的package包/類
/**
 * Replaces the dialect placeholder in the resource URL and attempts to find a file for
 * it.  If not found, the dialect hierarchy will be walked until a compatible resource is
 * found.  This makes it possible to have resources that are generic to all dialects.
 * 
 * @return The Resource, otherwise null
 */
private Resource getDialectResource(Class<?> dialectClass, String resourceUrl)
{
    // replace the dialect placeholder
    String dialectResourceUrl = resolveDialectUrl(dialectClass, resourceUrl);
    // get a handle on the resource
    Resource resource = rpr.getResource(dialectResourceUrl);
    if (!resource.exists())
    {
        // it wasn't found.  Get the superclass of the dialect and try again
        Class<?> superClass = dialectClass.getSuperclass();
        if (Dialect.class.isAssignableFrom(superClass))
        {
            // we still have a Dialect - try again
            return getDialectResource(superClass, resourceUrl);
        }
        else
        {
            // we have exhausted all options
            return null;
        }
    }
    else
    {
        // we have a handle to it
        return resource;
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:35,代碼來源:SchemaBootstrap.java


注:本文中的org.hibernate.dialect.Dialect類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。