KickJava   Java API By Example, From Geeks To Geeks.

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


1 //$Id: MckoiDialect.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.Hibernate;
7 import org.hibernate.cfg.Environment;
8 import org.hibernate.dialect.function.StandardSQLFunction;
9 import org.hibernate.sql.CaseFragment;
10 import org.hibernate.sql.MckoiCaseFragment;
11
12 /**
13  * An SQL dialect compatible with McKoi SQL
14  * @author Doug Currie, Gabe Hicks
15  */

16 public class MckoiDialect extends Dialect {
17     public MckoiDialect() {
18         super();
19         registerColumnType( Types.BIT, "bit" );
20         registerColumnType( Types.BIGINT, "bigint" );
21         registerColumnType( Types.SMALLINT, "smallint" );
22         registerColumnType( Types.TINYINT, "tinyint" );
23         registerColumnType( Types.INTEGER, "integer" );
24         registerColumnType( Types.CHAR, "char(1)" );
25         registerColumnType( Types.VARCHAR, "varchar($l)" );
26         registerColumnType( Types.FLOAT, "float" );
27         registerColumnType( Types.DOUBLE, "double" );
28         registerColumnType( Types.DATE, "date" );
29         registerColumnType( Types.TIME, "time" );
30         registerColumnType( Types.TIMESTAMP, "timestamp" );
31         registerColumnType( Types.VARBINARY, "varbinary" );
32         registerColumnType( Types.NUMERIC, "numeric" );
33         registerColumnType( Types.BLOB, "blob" );
34         registerColumnType( Types.CLOB, "clob" );
35
36         registerFunction( "upper", new StandardSQLFunction("upper") );
37         registerFunction( "lower", new StandardSQLFunction("lower") );
38         registerFunction( "sqrt", new StandardSQLFunction("sqrt", Hibernate.DOUBLE) );
39         registerFunction( "abs", new StandardSQLFunction("abs") );
40         registerFunction( "sign", new StandardSQLFunction( "sign", Hibernate.INTEGER ) );
41         registerFunction( "length", new StandardSQLFunction( "length", Hibernate.INTEGER ) );
42         registerFunction( "round", new StandardSQLFunction( "round", Hibernate.INTEGER ) );
43         registerFunction( "mod", new StandardSQLFunction( "mod", Hibernate.INTEGER ) );
44         registerFunction( "least", new StandardSQLFunction("least") );
45         registerFunction( "greatest", new StandardSQLFunction("greatest") );
46         registerFunction( "user", new StandardSQLFunction( "user", Hibernate.STRING ) );
47         registerFunction( "concat", new StandardSQLFunction( "concat", Hibernate.STRING ) );
48
49         getDefaultProperties().setProperty(Environment.STATEMENT_BATCH_SIZE, NO_BATCH);
50     }
51
52     public String JavaDoc getAddColumnString() {
53         return "add column";
54     }
55
56     public String JavaDoc getSequenceNextValString(String JavaDoc sequenceName) {
57         return "select " + getSelectSequenceNextValString( sequenceName );
58     }
59
60     public String JavaDoc getSelectSequenceNextValString(String JavaDoc sequenceName) {
61         return "nextval('" + sequenceName + "')";
62     }
63
64     public String JavaDoc getCreateSequenceString(String JavaDoc sequenceName) {
65         return "create sequence " + sequenceName;
66     }
67
68     public String JavaDoc getDropSequenceString(String JavaDoc sequenceName) {
69         return "drop sequence " + sequenceName;
70     }
71
72     public String JavaDoc getForUpdateString() {
73         return "";
74     }
75
76     public boolean supportsSequences() {
77         return true;
78     }
79
80     public CaseFragment createCaseFragment() {
81         return new MckoiCaseFragment();
82     }
83
84 }
85
Popular Tags