/*
* 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;
import java.sql.Types;
import java.util.Properties;
import org.hibernate.cfg.Environment;
A SQL dialect for Ingres 10 and later versions.
Changes:
- Add native BOOLEAN type support
- Add identity column support
Author: Raymond Fan
/**
* A SQL dialect for Ingres 10 and later versions.
* <p/>
* Changes:
* <ul>
* <li>Add native BOOLEAN type support</li>
* <li>Add identity column support</li>
* </ul>
*
* @author Raymond Fan
*/
public class Ingres10Dialect extends Ingres9Dialect {
Constructs a Ingres10Dialect
/**
* Constructs a Ingres10Dialect
*/
public Ingres10Dialect() {
super();
registerBooleanSupport();
registerDefaultProperties();
}
protected void registerBooleanSupport() {
// Boolean type (mapping/BooleanType) mapping maps SQL BIT to Java
// Boolean. In order to create a boolean column, BIT needs to be mapped
// to boolean as well, similar to H2Dialect.
registerColumnType( Types.BIT, "boolean" );
registerColumnType( Types.BOOLEAN, "boolean" );
}
private void registerDefaultProperties() {
// true, false and unknown are now valid values
// Remove the query substitutions previously added in IngresDialect.
final Properties properties = getDefaultProperties();
final String querySubst = properties.getProperty( Environment.QUERY_SUBSTITUTIONS );
if ( querySubst != null ) {
final String newQuerySubst = querySubst.replace( "true=1,false=0", "" );
properties.setProperty( Environment.QUERY_SUBSTITUTIONS, newQuerySubst );
}
}
// IDENTITY support ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@Override
public String toBooleanValueString(boolean bool) {
return bool ? "true" : "false";
}
@Override
public boolean supportsIdentityColumns() {
return true;
}
@Override
public boolean hasDataTypeInIdentityColumn() {
return true;
}
@Override
public String getIdentitySelectString() {
return "select last_identity()";
}
@Override
public String getIdentityColumnString() {
return "not null generated by default as identity";
}
@Override
public String getIdentityInsertString() {
return "default";
}
}