1 package org.apache.torque.engine.platform;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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 }