001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * // Copyright (c) 1998, 2007, Oracle. All rights reserved.
005: *
006: *
007: * The contents of this file are subject to the terms of either the GNU
008: * General Public License Version 2 only ("GPL") or the Common Development
009: * and Distribution License("CDDL") (collectively, the "License"). You
010: * may not use this file except in compliance with the License. You can obtain
011: * a copy of the License at https://glassfish.dev.java.net/public/CDDL+GPL.html
012: * or glassfish/bootstrap/legal/LICENSE.txt. See the License for the specific
013: * language governing permissions and limitations under the License.
014: *
015: * When distributing the software, include this License Header Notice in each
016: * file and include the License file at glassfish/bootstrap/legal/LICENSE.txt.
017: * Sun designates this particular file as subject to the "Classpath" exception
018: * as provided by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the License
020: * Header, with the fields enclosed by brackets [] replaced by your own
021: * identifying information: "Portions Copyrighted [year]
022: * [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * If you wish your version of this file to be governed by only the CDDL or
027: * only the GPL Version 2, indicate your decision by adding "[Contributor]
028: * elects to include this software in this distribution under the [CDDL or GPL
029: * Version 2] license." If you don't indicate a single choice of license, a
030: * recipient has the option to distribute your version of this file under
031: * either the CDDL, the GPL Version 2 or to extend the choice of license to
032: * its licensees as provided above. However, if you add GPL Version 2 code
033: * and therefore, elected the GPL Version 2 license, then the option applies
034: * only if the new code is made subject to such option by the copyright
035: * holder.
036: */
037: package oracle.toplink.essentials.platform.database;
038:
039: import java.util.*;
040: import oracle.toplink.essentials.internal.databaseaccess.*;
041:
042: /**
043: * <p><b>Purpose</b>: Provides HSQL specific behaviour.
044: *
045: * @since TOPLink/Java 4.5
046: */
047: public class HSQLPlatform extends DatabasePlatform {
048: public HSQLPlatform() {
049: }
050:
051: protected Hashtable buildFieldTypes() {
052: Hashtable fieldTypeMapping;
053:
054: fieldTypeMapping = super .buildFieldTypes();
055: fieldTypeMapping.put(Boolean.class, new FieldTypeDefinition(
056: "TINYINT", false));
057:
058: fieldTypeMapping.put(Integer.class, new FieldTypeDefinition(
059: "INTEGER", false));
060: fieldTypeMapping.put(Long.class, new FieldTypeDefinition(
061: "NUMERIC", 19));
062: fieldTypeMapping.put(Float.class, new FieldTypeDefinition(
063: "REAL", false));
064: fieldTypeMapping.put(Double.class, new FieldTypeDefinition(
065: "REAL", false));
066: fieldTypeMapping.put(Short.class, new FieldTypeDefinition(
067: "SMALLINT", false));
068: fieldTypeMapping.put(Byte.class, new FieldTypeDefinition(
069: "SMALLINT", false));
070: fieldTypeMapping.put(java.math.BigInteger.class,
071: new FieldTypeDefinition("NUMERIC", 38));
072: fieldTypeMapping.put(java.math.BigDecimal.class,
073: new FieldTypeDefinition("NUMERIC", 38).setLimits(38,
074: -19, 19));
075: fieldTypeMapping.put(Number.class, new FieldTypeDefinition(
076: "NUMERIC", 38).setLimits(38, -19, 19));
077: fieldTypeMapping.put(Byte[].class, new FieldTypeDefinition(
078: "BINARY", false));
079: fieldTypeMapping.put(Character[].class,
080: new FieldTypeDefinition("LONGVARCHAR", false));
081: fieldTypeMapping.put(byte[].class, new FieldTypeDefinition(
082: "BINARY", false));
083: fieldTypeMapping.put(char[].class, new FieldTypeDefinition(
084: "LONGVARCHAR", false));
085: fieldTypeMapping.put(java.sql.Blob.class,
086: new FieldTypeDefinition("BINARY", false));
087: fieldTypeMapping.put(java.sql.Clob.class,
088: new FieldTypeDefinition("LONGVARCHAR", false));
089:
090: return fieldTypeMapping;
091: }
092:
093: public boolean isHSQL() {
094: return true;
095: }
096:
097: /**
098: * INTERNAL:
099: * HSQL 1.6.1 does not support the ALTER TABLE method of create foreign key constraints
100: */
101: public boolean supportsForeignKeyConstraints() {
102: return false;
103: }
104: }
|