/** * 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; }
@Override public boolean matches(Object object) { DialectResolver actual = (DialectResolver) object; DialectResolutionInfo info = mock(DialectResolutionInfo.class); when(info.getDatabaseName()).thenReturn(databaseName); if ("SQLite".equals(databaseName)) { return actual.resolveDialect(info) instanceof SQLiteDialect; } else { return actual.resolveDialect(info) == null; } }
@Override public Dialect resolveDialect(DialectResolutionInfo info) { if ("DB2".equals(info.getDatabaseName())) { LOG.debug("DB2 detected returning DB2390Dialect"); return new DB2390Dialect(); } return null; }
@Override public Dialect resolveDialect(DialectResolutionInfo dialectResolutionInfo) { if ("MySQL".equals(dialectResolutionInfo.getDatabaseName())) { return dialectResolutionInfo.getDatabaseMajorVersion() >= 5 ? new Mysql5BitBooleanDialect() : new MySQLDialect(); } return null; }
@Override public Dialect resolveDialect(DialectResolutionInfo info) { if (info.getDatabaseName().equals("SQLite")) return dialect; return null; }
@Nullable @Override public Dialect resolveDialect(DialectResolutionInfo info) { return (info.getDatabaseName().equals(HsqlDatabaseProperties.PRODUCT_NAME) ? SdcctHsqlDialect.INSTANCE : null); }
@Override public Dialect resolveDialect(final DialectResolutionInfo info) { return new AllowMissingIdentitySupportDialect(super.resolveDialect(info)); }