Skip to content

Commit

Permalink
HHH-7009 Create new PostgreSQL 8.2 Dialect
Browse files Browse the repository at this point in the history
Create dialect for Postgres 8.2 and later which supports "if exists"
in drop statements. Update resolver to return the correct dialect
version.
  • Loading branch information
edalquist authored and gbadner committed Feb 6, 2012
1 parent 5448e8b commit b729230
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 5 deletions.
@@ -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 8.2 and later, adds support for "if exists" when dropping tables
*
* @author edalquist
*/
public class PostgreSQL82Dialect extends PostgreSQLDialect {
@Override
public boolean supportsIfExistsBeforeTableName() {
return true;
}
}
Expand Up @@ -396,11 +396,6 @@ protected String getCreateSequenceString(String sequenceName, int initialValue,
// }


@Override
public boolean supportsIfExistsBeforeTableName() {
return true;
}

public boolean supportsEmptyInList() {
return false;
}
Expand Down
Expand Up @@ -45,6 +45,7 @@
import org.hibernate.dialect.Oracle10gDialect;
import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.dialect.Oracle9iDialect;
import org.hibernate.dialect.PostgreSQL82Dialect;
import org.hibernate.dialect.PostgreSQLDialect;
import org.hibernate.dialect.SQLServer2005Dialect;
import org.hibernate.dialect.SQLServer2008Dialect;
Expand Down Expand Up @@ -85,6 +86,10 @@ protected Dialect resolveDialectInternal(DatabaseMetaData metaData) throws SQLEx
}

if ( "PostgreSQL".equals( databaseName ) ) {
final int databaseMinorVersion = metaData.getDatabaseMinorVersion();
if (databaseMajorVersion >= 8 && databaseMinorVersion >= 2) {
return new PostgreSQL82Dialect();
}
return new PostgreSQLDialect();
}

Expand Down

0 comments on commit b729230

Please sign in to comment.