KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > dialect > InterbaseDialect


1 //$Id: InterbaseDialect.java,v 1.7 2005/07/07 02:39:10 steveebersole Exp $
2
package org.hibernate.dialect;
3
4 import java.sql.Types JavaDoc;
5
6 import org.hibernate.cfg.Environment;
7
8 /**
9  * An SQL dialect for Interbase.
10  * @author Gavin King
11  */

12 public class InterbaseDialect extends Dialect {
13
14     public InterbaseDialect() {
15         super();
16         registerColumnType( Types.BIT, "smallint" );
17         registerColumnType( Types.BIGINT, "numeric(18,0)" );
18         registerColumnType( Types.SMALLINT, "smallint" );
19         registerColumnType( Types.TINYINT, "smallint" );
20         registerColumnType( Types.INTEGER, "integer" );
21         registerColumnType( Types.CHAR, "char(1)" );
22         registerColumnType( Types.VARCHAR, "varchar($l)" );
23         registerColumnType( Types.FLOAT, "float" );
24         registerColumnType( Types.DOUBLE, "double precision" );
25         registerColumnType( Types.DATE, "date" );
26         registerColumnType( Types.TIME, "time" );
27         registerColumnType( Types.TIMESTAMP, "timestamp" );
28         registerColumnType( Types.VARBINARY, "blob" );
29         registerColumnType( Types.NUMERIC, "numeric($p,$s)" );
30         registerColumnType( Types.BLOB, "blob" );
31         registerColumnType( Types.CLOB, "blob sub_type 1" );
32
33         getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
34     }
35
36     public String JavaDoc getAddColumnString() {
37         return "add";
38     }
39
40     public String JavaDoc getSequenceNextValString(String JavaDoc sequenceName) {
41         return "select " + getSelectSequenceNextValString( sequenceName ) + " from RDB$DATABASE";
42     }
43
44     public String JavaDoc getSelectSequenceNextValString(String JavaDoc sequenceName) {
45         return "gen_id( " + sequenceName + ", 1 )";
46     }
47
48     public String JavaDoc getCreateSequenceString(String JavaDoc sequenceName) {
49         return "create generator " + sequenceName;
50     }
51
52     public String JavaDoc getDropSequenceString(String JavaDoc sequenceName) {
53         return "delete from RDB$GENERATORS where RDB$GENERATOR_NAME = '" + sequenceName.toUpperCase() + "'";
54     }
55
56     public String JavaDoc getQuerySequencesString() {
57         return "select RDB$GENERATOR_NAME from RDB$GENERATORS";
58     }
59     
60     public String JavaDoc getForUpdateString() {
61         return " with lock";
62     }
63     public String JavaDoc getForUpdateString(String JavaDoc aliases) {
64         return " for update of " + aliases + " with lock";
65     }
66
67     public boolean supportsSequences() {
68         return true;
69     }
70
71     public boolean supportsLimit() {
72         return true;
73     }
74
75     public String JavaDoc getLimitString(String JavaDoc sql, boolean hasOffset) {
76         return new StringBuffer JavaDoc( sql.length()+15 )
77             .append(sql)
78             .append(hasOffset ? " rows ? to ?" : " rows ?")
79             .toString();
80     }
81
82     public boolean bindLimitParametersFirst() {
83         return false;
84     }
85
86     public boolean bindLimitParametersInReverseOrder() {
87         return false;
88     }
89
90 }
Popular Tags