View Javadoc

1   package org.apache.torque.engine.platform;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.torque.engine.database.model.Domain;
23  import org.apache.torque.engine.database.model.SchemaType;
24  import org.apache.torque.engine.database.model.SizedForBitDataDomain;
25  
26  /***
27   * Derby Platform implementation.
28   *
29   * @author <a href="mailto:johnnymac@tiscali.be">Johnny Macchione</a>
30   * @author <a href="Monroe@DukeCE.com">Greg Monroe</a>
31   * @version $Id: PlatformDerbyImpl.java 482880 2006-12-06 03:55:24Z gmonroe $
32   */
33  public class PlatformDerbyImpl extends PlatformDefaultImpl
34  {
35  
36      /***
37       * Default constructor.
38       */
39      public PlatformDerbyImpl()
40      {
41          super();
42          initialize();
43      }
44  
45      /***
46       * Initializes db specific domain mapping.
47       */
48      private void initialize()
49      {
50          setSchemaDomainMapping(
51                      new Domain(SchemaType.LONGVARCHAR, "LONG VARCHAR"));
52  
53          setSchemaDomainMapping( new SizedForBitDataDomain(
54                                      SchemaType.VARBINARY, "VARCHAR", "32672"));
55          setSchemaDomainMapping(
56                  new SizedForBitDataDomain(SchemaType.BINARY, "CHAR", "1"));
57          setSchemaDomainMapping( new Domain(SchemaType.LONGVARBINARY,
58                                                  "LONG VARCHAR FOR BIT DATA"));
59          setSchemaDomainMapping(
60                  new Domain(SchemaType.LONGVARCHAR, "LONG VARCHAR"));
61          setSchemaDomainMapping(
62                  new Domain(SchemaType.BIT,"CHAR(1)"));
63          setSchemaDomainMapping(
64                  new Domain(SchemaType.TINYINT, "SMALLINT"));
65      }
66  
67      /***
68       * @see Platform#getMaxColumnNameLength()
69       */
70      public int getMaxColumnNameLength()
71      {
72          return 128;
73      }
74  
75      /***
76       * @see Platform#getAutoIncrement()
77       */
78      public String getAutoIncrement()
79      {
80          return "GENERATED BY DEFAULT AS IDENTITY";
81      }
82  
83      /***
84       * @see Platform#getNativeIdMethod()
85       */
86      public String getNativeIdMethod()
87      {
88          return Platform.IDENTITY;
89      }
90  
91      /***
92       * @see Platform#hasScale(String)
93       */
94      public boolean hasScale(String sqlType)
95      {
96          return "NUMERIC".equals(sqlType) || "DECIMAL".equals(sqlType);
97      }
98  
99      /***
100      * @see Platform#hasSize(String)
101      */
102     public boolean hasSize(String sqlType)
103     {
104         return "NUMERIC".equals(sqlType) || "DECIMAL".equals(sqlType)
105             || "VARCHAR".equals(sqlType) || "CHAR".equals(sqlType)
106             || "BINARY".equals(sqlType) || "VARBINARY".equals(sqlType)
107             || "BLOB".equals(sqlType) || "CLOB".equals(sqlType);
108     }
109 }