Open Source Repository

Home /hibernate/hibernate-3.2.7.ga | Repository Home



org/hibernate/dialect/FrontBaseDialect.java
//$Id: FrontBaseDialect.java 9328 2006-02-23 17:32:47Z steveebersole $
package org.hibernate.dialect;

import org.hibernate.dialect.lock.LockingStrategy;
import org.hibernate.dialect.lock.UpdateLockingStrategy;
import org.hibernate.dialect.lock.SelectLockingStrategy;
import org.hibernate.persister.entity.Lockable;
import org.hibernate.LockMode;

import java.sql.Types;

/**
 * An SQL Dialect for Frontbase.  Assumes you're using the latest version
 * of the FrontBase JDBC driver, available from <tt>http://frontbase.com/</tt>
 <p>
 <b>NOTE</b>: The latest JDBC driver is not always included with the
 * latest release of FrontBase.  Download the driver separately, and enjoy
 * the informative release notes.
 <p>
 * This dialect was tested with JDBC driver version 2.3.1.  This driver
 * contains a bug that causes batches of updates to fail.  (The bug should be
 * fixed in the next release of the JDBC driver.)  If you are using JDBC driver
 * 2.3.1, you can work-around this problem by setting the following in your
 <tt>hibernate.properties</tt> file: <tt>hibernate.jdbc.batch_size=15</tt>
 *
 @author Ron Lussier <tt>[email protected]</tt>
 */
public class FrontBaseDialect extends Dialect {

  public FrontBaseDialect() {
    super();

    registerColumnTypeTypes.BIT, "bit" );
    registerColumnTypeTypes.BIGINT, "longint" );
    registerColumnTypeTypes.SMALLINT, "smallint" );
    registerColumnTypeTypes.TINYINT, "tinyint" );
    registerColumnTypeTypes.INTEGER, "integer" );
    registerColumnTypeTypes.CHAR, "char(1)" );
    registerColumnTypeTypes.VARCHAR, "varchar($l)" );
    registerColumnTypeTypes.FLOAT, "float" );
    registerColumnTypeTypes.DOUBLE, "double precision" );
    registerColumnTypeTypes.DATE, "date" );
    registerColumnTypeTypes.TIME, "time" );
    registerColumnTypeTypes.TIMESTAMP, "timestamp" );
    registerColumnTypeTypes.VARBINARY, "bit varying($l)" );
    registerColumnTypeTypes.NUMERIC, "numeric($p,$s)" );
    registerColumnTypeTypes.BLOB, "blob" );
    registerColumnTypeTypes.CLOB, "clob" );
  }

  public String getAddColumnString() {
    return "add column";
  }

  public String getCascadeConstraintsString() {
    return " cascade";
  }

  public boolean dropConstraints() {
    return false;
  }

  /**
   * Does this dialect support the <tt>FOR UPDATE</tt> syntax. No!
   *
   @return false always. FrontBase doesn't support this syntax,
   * which was dropped with SQL92
   */
  public String getForUpdateString() {
    return "";
  }

  public String getCurrentTimestampCallString() {
    // TODO : not sure this is correct, could not find docs on how to do this.
    return "{?= call current_timestamp}";
  }

  public boolean isCurrentTimestampSelectStringCallable() {
    return true;
  }

  public LockingStrategy getLockingStrategy(Lockable lockable, LockMode lockMode) {
    // Frontbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
    if lockMode.greaterThanLockMode.READ ) ) {
      return new UpdateLockingStrategylockable, lockMode );
    }
    else {
      return new SelectLockingStrategylockable, lockMode );
    }
  }
}