HHH-8331 Create PostgreSQL9Dialect
This commit is contained in:
parent
c785c5e7a8
commit
edf1fa9fbc
|
@ -27,9 +27,9 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
||||
import org.hibernate.boot.registry.selector.StrategyRegistration;
|
||||
import org.hibernate.boot.registry.selector.StrategyRegistrationProvider;
|
||||
import org.hibernate.boot.registry.selector.SimpleStrategyRegistrationImpl;
|
||||
import org.hibernate.boot.registry.selector.spi.StrategySelectionException;
|
||||
import org.hibernate.boot.registry.selector.spi.StrategySelector;
|
||||
import org.hibernate.dialect.CUBRIDDialect;
|
||||
|
@ -61,6 +61,7 @@ import org.hibernate.dialect.Oracle9iDialect;
|
|||
import org.hibernate.dialect.PointbaseDialect;
|
||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||
import org.hibernate.dialect.PostgreSQL9Dialect;
|
||||
import org.hibernate.dialect.PostgresPlusDialect;
|
||||
import org.hibernate.dialect.ProgressDialect;
|
||||
import org.hibernate.dialect.SAPDBDialect;
|
||||
|
@ -219,6 +220,7 @@ public class StrategySelectorBuilder {
|
|||
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 );
|
||||
|
|
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.dialect;
|
||||
|
||||
/**
|
||||
* An SQL dialect for Postgres 9 and later. Adds support for "if exists" when dropping constraints
|
||||
*
|
||||
* @author edalquist
|
||||
*/
|
||||
public class PostgreSQL9Dialect extends PostgreSQL81Dialect {
|
||||
@Override
|
||||
public boolean supportsIfExistsBeforeConstraintName() {
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -23,8 +23,6 @@
|
|||
*/
|
||||
package org.hibernate.engine.jdbc.dialect.internal;
|
||||
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
import org.hibernate.dialect.CUBRIDDialect;
|
||||
import org.hibernate.dialect.DB2400Dialect;
|
||||
import org.hibernate.dialect.DB2Dialect;
|
||||
|
@ -45,6 +43,7 @@ import org.hibernate.dialect.Oracle8iDialect;
|
|||
import org.hibernate.dialect.Oracle9iDialect;
|
||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||
import org.hibernate.dialect.PostgreSQL9Dialect;
|
||||
import org.hibernate.dialect.SQLServer2005Dialect;
|
||||
import org.hibernate.dialect.SQLServer2008Dialect;
|
||||
import org.hibernate.dialect.SQLServerDialect;
|
||||
|
@ -52,6 +51,7 @@ import org.hibernate.dialect.SybaseASE15Dialect;
|
|||
import org.hibernate.dialect.SybaseAnywhereDialect;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DatabaseInfoDialectResolver;
|
||||
import org.hibernate.internal.CoreMessageLogger;
|
||||
import org.jboss.logging.Logger;
|
||||
|
||||
/**
|
||||
* The standard DatabaseInfoDialectResolver implementation
|
||||
|
@ -93,10 +93,11 @@ public class StandardDatabaseInfoDialectResolver implements DatabaseInfoDialectR
|
|||
final int majorVersion = databaseInfo.getDatabaseMajorVersion();
|
||||
final int minorVersion = databaseInfo.getDatabaseMinorVersion();
|
||||
|
||||
if ( majorVersion > 8 || ( majorVersion == 8 && minorVersion >= 2 ) ) {
|
||||
return new PostgreSQL82Dialect();
|
||||
if ( majorVersion == 8 ) {
|
||||
return minorVersion >= 2 ? new PostgreSQL82Dialect() : new PostgreSQL81Dialect();
|
||||
}
|
||||
return new PostgreSQL81Dialect();
|
||||
|
||||
return new PostgreSQL9Dialect();
|
||||
}
|
||||
|
||||
if ( "Apache Derby".equals( databaseName ) ) {
|
||||
|
|
|
@ -23,6 +23,10 @@
|
|||
*/
|
||||
package org.hibernate.dialect.resolver;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
|
@ -51,6 +55,7 @@ import org.hibernate.dialect.Oracle8iDialect;
|
|||
import org.hibernate.dialect.Oracle9iDialect;
|
||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||
import org.hibernate.dialect.PostgreSQL9Dialect;
|
||||
import org.hibernate.dialect.SQLServerDialect;
|
||||
import org.hibernate.dialect.SybaseASE15Dialect;
|
||||
import org.hibernate.dialect.SybaseAnywhereDialect;
|
||||
|
@ -60,16 +65,10 @@ import org.hibernate.engine.jdbc.dialect.internal.DialectResolverSet;
|
|||
import org.hibernate.engine.jdbc.dialect.internal.StandardDatabaseInfoDialectResolver;
|
||||
import org.hibernate.engine.jdbc.dialect.internal.StandardDatabaseMetaDataDialectResolver;
|
||||
import org.hibernate.engine.jdbc.dialect.spi.DialectResolver;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
|
@ -148,6 +147,7 @@ public class DialectFactoryTest extends BaseUnitTestCase {
|
|||
testDetermination( "MySQL", MySQLDialect.class, resolver );
|
||||
testDetermination( "PostgreSQL", PostgreSQL81Dialect.class, resolver );
|
||||
testDetermination( "PostgreSQL", 8, 2, PostgreSQL82Dialect.class, resolver );
|
||||
testDetermination( "PostgreSQL", 9, 0, PostgreSQL9Dialect.class, resolver );
|
||||
testDetermination( "Apache Derby", 10, 4, DerbyDialect.class, resolver );
|
||||
testDetermination( "Apache Derby", 10, 5, DerbyTenFiveDialect.class, resolver );
|
||||
testDetermination( "Apache Derby", 10, 6, DerbyTenSixDialect.class, resolver );
|
||||
|
|
|
@ -35,6 +35,7 @@ import java.sql.SQLException;
|
|||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.dialect.PostgreSQL81Dialect;
|
||||
import org.hibernate.dialect.PostgreSQL82Dialect;
|
||||
import org.hibernate.dialect.PostgreSQL9Dialect;
|
||||
import org.hibernate.dialect.SQLServer2005Dialect;
|
||||
import org.hibernate.dialect.SQLServer2008Dialect;
|
||||
import org.hibernate.dialect.SQLServerDialect;
|
||||
|
@ -102,17 +103,17 @@ public class StandardDatabaseMetaDataDialectResolverTest extends BaseUnitTestCas
|
|||
|
||||
@Test
|
||||
public void testResolveDialectInternalForPostgres9() throws SQLException {
|
||||
runPostgresDialectTest( 9, 0, PostgreSQL82Dialect.class );
|
||||
runPostgresDialectTest( 9, 0, PostgreSQL9Dialect.class );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDialectInternalForPostgres91() throws SQLException {
|
||||
runPostgresDialectTest( 9, 1, PostgreSQL82Dialect.class );
|
||||
runPostgresDialectTest( 9, 1, PostgreSQL9Dialect.class );
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testResolveDialectInternalForPostgres92() throws SQLException {
|
||||
runPostgresDialectTest( 9, 2, PostgreSQL82Dialect.class );
|
||||
runPostgresDialectTest( 9, 2, PostgreSQL9Dialect.class );
|
||||
}
|
||||
|
||||
private static void runSQLServerDialectTest(
|
||||
|
|
Loading…
Reference in New Issue