01: //$Id: FrontBaseDialect.java 9328 2006-02-23 17:32:47Z steveebersole $
02: package org.hibernate.dialect;
03:
04: import org.hibernate.dialect.lock.LockingStrategy;
05: import org.hibernate.dialect.lock.UpdateLockingStrategy;
06: import org.hibernate.dialect.lock.SelectLockingStrategy;
07: import org.hibernate.persister.entity.Lockable;
08: import org.hibernate.LockMode;
09:
10: import java.sql.Types;
11:
12: /**
13: * An SQL Dialect for Frontbase. Assumes you're using the latest version
14: * of the FrontBase JDBC driver, available from <tt>http://frontbase.com/</tt>
15: * <p>
16: * <b>NOTE</b>: The latest JDBC driver is not always included with the
17: * latest release of FrontBase. Download the driver separately, and enjoy
18: * the informative release notes.
19: * <p>
20: * This dialect was tested with JDBC driver version 2.3.1. This driver
21: * contains a bug that causes batches of updates to fail. (The bug should be
22: * fixed in the next release of the JDBC driver.) If you are using JDBC driver
23: * 2.3.1, you can work-around this problem by setting the following in your
24: * <tt>hibernate.properties</tt> file: <tt>hibernate.jdbc.batch_size=15</tt>
25: *
26: * @author Ron Lussier <tt>rlussier@lenscraft.com</tt>
27: */
28: public class FrontBaseDialect extends Dialect {
29:
30: public FrontBaseDialect() {
31: super ();
32:
33: registerColumnType(Types.BIT, "bit");
34: registerColumnType(Types.BIGINT, "longint");
35: registerColumnType(Types.SMALLINT, "smallint");
36: registerColumnType(Types.TINYINT, "tinyint");
37: registerColumnType(Types.INTEGER, "integer");
38: registerColumnType(Types.CHAR, "char(1)");
39: registerColumnType(Types.VARCHAR, "varchar($l)");
40: registerColumnType(Types.FLOAT, "float");
41: registerColumnType(Types.DOUBLE, "double precision");
42: registerColumnType(Types.DATE, "date");
43: registerColumnType(Types.TIME, "time");
44: registerColumnType(Types.TIMESTAMP, "timestamp");
45: registerColumnType(Types.VARBINARY, "bit varying($l)");
46: registerColumnType(Types.NUMERIC, "numeric($p,$s)");
47: registerColumnType(Types.BLOB, "blob");
48: registerColumnType(Types.CLOB, "clob");
49: }
50:
51: public String getAddColumnString() {
52: return "add column";
53: }
54:
55: public String getCascadeConstraintsString() {
56: return " cascade";
57: }
58:
59: public boolean dropConstraints() {
60: return false;
61: }
62:
63: /**
64: * Does this dialect support the <tt>FOR UPDATE</tt> syntax. No!
65: *
66: * @return false always. FrontBase doesn't support this syntax,
67: * which was dropped with SQL92
68: */
69: public String getForUpdateString() {
70: return "";
71: }
72:
73: public String getCurrentTimestampCallString() {
74: // TODO : not sure this is correct, could not find docs on how to do this.
75: return "{?= call current_timestamp}";
76: }
77:
78: public boolean isCurrentTimestampSelectStringCallable() {
79: return true;
80: }
81:
82: public LockingStrategy getLockingStrategy(Lockable lockable,
83: LockMode lockMode) {
84: // Frontbase has no known variation of a "SELECT ... FOR UPDATE" syntax...
85: if (lockMode.greaterThan(LockMode.READ)) {
86: return new UpdateLockingStrategy(lockable, lockMode);
87: } else {
88: return new SelectLockingStrategy(lockable, lockMode);
89: }
90: }
91: }
|