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.mssql;
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:
027: /**
028: * Final TypeMapper for Microsoft SQL server database.
029: *
030: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
031: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
032: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
033: * @since 1.1
034: */
035: public final class MssqlTypeMapper extends AbstractTypeMapper {
036: //--------------------------------------------------------------------------
037:
038: /** The <a href="http://jakarta.apache.org/commons/logging/">Jakarta Commons
039: * Logging </a> instance used for all logging. */
040: private static final Log LOG = LogFactory
041: .getLog(MssqlTypeMapper.class);
042:
043: //--------------------------------------------------------------------------
044:
045: /**
046: * Construct a TypeMapper for Oracle database using given configuration to get default
047: * parameters for parameterized types.
048: *
049: * @param conf The configuration to get default parameter values from.
050: */
051: public MssqlTypeMapper(final DDLGenConfiguration conf) {
052: super (conf);
053: }
054:
055: //--------------------------------------------------------------------------
056:
057: /**
058: * {@inheritDoc}
059: */
060: protected void initialize(final DDLGenConfiguration conf) {
061: // numeric types
062: this .add(new NoParamType("bit", "BIT"));
063: this .add(new NoParamType("tinyint", "TINYINT"));
064: this .add(new NoParamType("smallint", "SMALLINT"));
065: this .add(new NoParamType("integer", "INTEGER"));
066: this .add(new NoParamType("int", "INTEGER"));
067: this .add(new NoParamType("bigint", "BIGINT"));
068:
069: this .add(new OptionalPrecisionType("float", "FLOAT", conf));
070: this .add(new NoParamType("double", "DOUBLE PRECISION"));
071: this .add(new NoParamType("real", "REAL"));
072: this .add(new OptionalPrecisionDecimalsType("numeric",
073: "NUMERIC", conf));
074: this .add(new OptionalPrecisionDecimalsType("decimal",
075: "DECIMAL", conf));
076:
077: // character types
078: this .add(new OptionalLengthType("char", "CHAR", conf));
079: this .add(new OptionalLengthType("varchar", "VARCHAR", conf));
080: LOG
081: .warn("MS SQL does not support 'LONGVARCHAR' type, use TEXT instead.");
082: this .add(new NoParamType("longvarchar", "TEXT"));
083:
084: // date and time types
085: this .add(new NoParamType("date", "DATETIME"));
086: this .add(new NoParamType("time", "DATETIME"));
087: this .add(new NoParamType("timestamp", "TIMESTAMP"));
088:
089: // other types
090: this .add(new OptionalLengthType("binary", "BINARY", conf));
091: this
092: .add(new OptionalLengthType("varbinary", "VARBINARY",
093: conf));
094: this .add(new NoParamType("longvarbinary", "IMAGE"));
095:
096: this .add(new NoParamType("other", "IMAGE"));
097: this .add(new NoParamType("javaobject", "IMAGE"));
098: this .add(new NoParamType("blob", "IMAGE"));
099: this .add(new NoParamType("clob", "TEXT"));
100: }
101:
102: //--------------------------------------------------------------------------
103: }
|