@Override public Dialect resolveDialect(DialectResolutionInfo info) { for ( DialectResolver resolver : resolvers ) { try { final Dialect dialect = resolver.resolveDialect( info ); if ( dialect != null ) { return dialect; } } catch ( JDBCConnectionException e ) { throw e; } catch ( Exception e ) { LOG.exceptionInSubResolver( e.getMessage() ); } } return null; }
final String explicitDbMinor = (String) configurationValues.get( AvailableSettings.HBM2DDL_DB_MINOR_VERSION ); final Dialect indicatedDialect = serviceRegistry.getService( DialectResolver.class ).resolveDialect( new DialectResolutionInfo() { @Override
/** * 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; } }
try { DialectResolver dialectResolver = new StandardDialectResolver(); Dialect dialect = dialectResolver.resolveDialect(new DatabaseMetaDataDialectResolutionInfoAdapter(connection.getMetaData()));
@Override public Dialect resolveDialect(DialectResolutionInfo info) { for ( DialectResolver resolver : resolvers ) { try { final Dialect dialect = resolver.resolveDialect( info ); if ( dialect != null ) { return dialect; } } catch ( JDBCConnectionException e ) { throw e; } catch ( Exception e ) { LOG.exceptionInSubResolver( e.getMessage() ); } } return null; }
@Override public Long execute(Connection connection) throws SQLException { Long nextVal = 0L; // Determine what dialect we are using for this DB DialectResolver dialectResolver = new StandardDialectResolver(); Dialect dialect = dialectResolver .resolveDialect(new DatabaseMetaDataDialectResolutionInfoAdapter(connection.getMetaData())); // Find the next value in our sequence (based on DB dialect) try (PreparedStatement preparedStatement = connection .prepareStatement(dialect.getSequenceNextValString(HANDLE_SEQUENCE))) { // Execute query and return results try (ResultSet resultSet = preparedStatement.executeQuery()) { if (resultSet.next()) { // Return result of query (from first column) nextVal = resultSet.getLong(1); } } } return nextVal; } };
Dialect dialect = dialectResolver.resolveDialect(conn.getMetaData());
Dialect dialect = dialectResolver.resolveDialect(conn.getMetaData());
public String getDialect() { Connection connection = null; try { String dbName = (String) JdbcUtils.extractDatabaseMetaData(dataSource, "getDatabaseProductName"); connection = dataSource.getConnection(); DialectResolutionInfo dialectResolutionInfo = new DatabaseMetaDataDialectResolutionInfoAdapter(connection.getMetaData()); Dialect hibernateDialect = dialectResolver.resolveDialect(dialectResolutionInfo); String hibernateDialectClassName = hibernateDialect.getClass().getName(); if (GriffonNameUtils.isBlank(hibernateDialectClassName)) { throw new DatabaseException( "Could not determine Hibernate dialect for database name [" + dbName + "]!"); } return hibernateDialectClassName; } catch (SQLException e) { throw new DatabaseException(e); } finally { JdbcUtils.closeConnection(connection); } } }
public String getDialect() { Connection connection = null; try { String dbName = (String) JdbcUtils.extractDatabaseMetaData(dataSource, "getDatabaseProductName"); connection = dataSource.getConnection(); DialectResolutionInfo dialectResolutionInfo = new DatabaseMetaDataDialectResolutionInfoAdapter(connection.getMetaData()); Dialect hibernateDialect = dialectResolver.resolveDialect(dialectResolutionInfo); String hibernateDialectClassName = hibernateDialect.getClass().getName(); if (GriffonNameUtils.isBlank(hibernateDialectClassName)) { throw new DatabaseException( "Could not determine Hibernate dialect for database name [" + dbName + "]!"); } return hibernateDialectClassName; } catch (SQLException e) { throw new DatabaseException(e); } finally { JdbcUtils.closeConnection(connection); } } }
final String explicitDbMinor = (String) configurationValues.get( AvailableSettings.HBM2DDL_DB_MINOR_VERSION ); final Dialect indicatedDialect = serviceRegistry.getService( DialectResolver.class ).resolveDialect( new DialectResolutionInfo() { @Override
/** * 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; } }