本文整理汇总了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;
}
示例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 );
}
示例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;
}
示例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;
}
示例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 );
}
}
示例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());
}
示例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;
}
}
);
}
示例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 );
}
示例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;
}
示例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());
}
示例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();
}
示例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;
}
示例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" );
}
}
示例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;
}
示例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;
}
}