001: /*
002: * Copyright 2006 Le Duc Bao, Ralf Joachim
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
005: * use this file except in compliance with the License. You may obtain a copy of
006: * the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
012: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
013: * License for the specific language governing permissions and limitations under
014: * the License.
015: */
016: package org.castor.ddlgen.engine.oracle;
017:
018: import org.apache.commons.logging.Log;
019: import org.apache.commons.logging.LogFactory;
020: import org.castor.ddlgen.AbstractTypeMapper;
021: import org.castor.ddlgen.DDLGenConfiguration;
022: import org.castor.ddlgen.typeinfo.NoParamType;
023: import org.castor.ddlgen.typeinfo.OptionalLengthType;
024: import org.castor.ddlgen.typeinfo.OptionalPrecisionDecimalsType;
025: import org.castor.ddlgen.typeinfo.OptionalPrecisionType;
026: import org.castor.ddlgen.typeinfo.RequiredLengthType;
027:
028: /**
029: * Final TypeMapper for Oracle database.
030: *
031: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
032: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
033: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
034: * @since 1.1
035: */
036: public final class OracleTypeMapper extends AbstractTypeMapper {
037: //--------------------------------------------------------------------------
038:
039: /** The <a href="http://jakarta.apache.org/commons/logging/">Jakarta Commons
040: * Logging </a> instance used for all logging. */
041: private static final Log LOG = LogFactory
042: .getLog(OracleTypeMapper.class);
043:
044: //--------------------------------------------------------------------------
045:
046: /**
047: * Construct a TypeMapper for Oracle database using given configuration to get default
048: * parameters for parameterized types.
049: *
050: * @param conf The configuration to get default parameter values from.
051: */
052: public OracleTypeMapper(final DDLGenConfiguration conf) {
053: super (conf);
054: }
055:
056: //--------------------------------------------------------------------------
057:
058: /**
059: * {@inheritDoc}
060: */
061: protected void initialize(final DDLGenConfiguration conf) {
062: // numeric types
063: this .add(new NoParamType("bit", "BOOLEAN"));
064: LOG
065: .warn("Oracle does not support 'TINYINT' type, use SMALLINT instead.");
066: this .add(new NoParamType("tinyint", "SMALLINT"));
067: this .add(new NoParamType("smallint", "SMALLINT"));
068: this .add(new NoParamType("integer", "INTEGER"));
069: this .add(new NoParamType("int", "INTEGER"));
070: LOG
071: .warn("Oracle does not support 'BIGINT' type, use NUMERIC instead.");
072: this .add(new NoParamType("bigint", "NUMERIC"));
073:
074: this .add(new OptionalPrecisionType("float", "FLOAT", conf));
075: this .add(new NoParamType("double", "DOUBLE PRECISION"));
076: this .add(new NoParamType("real", "REAL"));
077: this .add(new OptionalPrecisionDecimalsType("numeric",
078: "NUMERIC", conf));
079: this .add(new OptionalPrecisionDecimalsType("decimal",
080: "DECIMAL", conf));
081:
082: // character types
083: this .add(new OptionalLengthType("char", "CHAR", conf));
084: this .add(new RequiredLengthType("varchar", "VARCHAR2", conf));
085: this .add(new NoParamType("longvarchar", "LONG"));
086:
087: // date and time types
088: this .add(new NoParamType("date", "DATE"));
089: this .add(new NoParamType("time", "DATE"));
090: this .add(new OptionalPrecisionType("timestamp", "TIMESTAMP",
091: conf));
092:
093: // other types
094: LOG
095: .warn("Oracle does not support 'BINARY' type, use BLOB instead.");
096: this .add(new NoParamType("binary", "BLOB"));
097: LOG
098: .warn("Oracle does not support 'VARBINARY' type, use BLOB instead.");
099: this .add(new NoParamType("varbinary", "BLOB"));
100: LOG.warn("Oracle does not support 'LONGVARBINARY' type, "
101: + "use BLOB instead.");
102: this .add(new NoParamType("longvarbinary", "BLOB"));
103:
104: this .add(new NoParamType("other", "BLOB"));
105: this .add(new NoParamType("javaobject", "BLOB"));
106: this .add(new NoParamType("blob", "BLOB"));
107: this .add(new NoParamType("clob", "CLOB"));
108: }
109:
110: //--------------------------------------------------------------------------
111: }
|