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 java.sql.Connection; |
23 |
|
import java.sql.DatabaseMetaData; |
24 |
|
import java.sql.PreparedStatement; |
25 |
|
import java.sql.ResultSet; |
26 |
|
import java.sql.SQLException; |
27 |
|
import java.util.List; |
28 |
|
|
29 |
|
import org.apache.torque.engine.database.model.Domain; |
30 |
|
import org.apache.torque.engine.database.model.SchemaType; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
@author |
36 |
|
@version |
37 |
|
|
|
|
| 0% |
Uncovered Elements: 74 (74) |
Complexity: 18 |
Complexity Density: 0.32 |
|
38 |
|
public class PlatformOracleImpl extends PlatformDefaultImpl { |
39 |
|
|
40 |
|
|
41 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
42 |
0
|
public PlatformOracleImpl() {... |
43 |
0
|
super(); |
44 |
0
|
initialize(); |
45 |
|
} |
46 |
|
|
47 |
|
|
48 |
|
|
49 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 1 |
Complexity Density: 0.06 |
|
50 |
0
|
private void initialize() {... |
51 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.TINYINT, "NUMBER", "3", "0")); |
52 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.SMALLINT, "NUMBER", "5", "0")); |
53 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.INTEGER, "NUMBER", "10", "0")); |
54 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.BOOLEANINT, "NUMBER", "1", "0")); |
55 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.BIGINT, "NUMBER", "20", "0")); |
56 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.REAL, "NUMBER")); |
57 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.DOUBLE, "FLOAT")); |
58 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.DECIMAL, "NUMBER")); |
59 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.NUMERIC, "NUMBER")); |
60 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.VARCHAR, "VARCHAR2")); |
61 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.LONGVARCHAR, "VARCHAR2", "2000")); |
62 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.TIME, "DATE")); |
63 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.TIMESTAMP, "TIMESTAMP")); |
64 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.BINARY, "LONG RAW")); |
65 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.VARBINARY, "BLOB")); |
66 |
0
|
setSchemaDomainMapping(new Domain(SchemaType.LONGVARBINARY, "LONG RAW")); |
67 |
|
} |
68 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
69 |
0
|
@Override... |
70 |
|
public String getSchemaName(String artifactId) { |
71 |
0
|
String s = super.getSchemaName(artifactId); |
72 |
0
|
return s.toUpperCase(); |
73 |
|
} |
74 |
|
|
75 |
|
|
76 |
|
@see |
77 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
78 |
0
|
public int getMaxColumnNameLength() {... |
79 |
0
|
return 30; |
80 |
|
} |
81 |
|
|
82 |
|
|
83 |
|
@see |
84 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
85 |
0
|
public String getNativeIdMethod() {... |
86 |
0
|
return Platform.SEQUENCE; |
87 |
|
} |
88 |
|
|
89 |
|
|
90 |
|
@see |
91 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
92 |
0
|
public String getAutoIncrement() {... |
93 |
0
|
return ""; |
94 |
|
} |
95 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
96 |
0
|
@Override... |
97 |
|
public List<String> getPrimaryKeys(DatabaseMetaData dbMeta, String dbSchema, String tableName) throws SQLException { |
98 |
0
|
return super.getPrimaryKeys(dbMeta, dbSchema.toUpperCase(), tableName); |
99 |
|
} |
100 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
101 |
0
|
public List<String> getTableNames(DatabaseMetaData dbMeta, String databaseSchema) throws SQLException {... |
102 |
0
|
return super.getTableNames(dbMeta, databaseSchema.toUpperCase()); |
103 |
|
} |
104 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 4 |
Complexity Density: 1 |
|
105 |
0
|
@Override... |
106 |
|
public boolean isSpecialDefault(String defaultValue) { |
107 |
0
|
defaultValue = defaultValue.toUpperCase(); |
108 |
0
|
if (defaultValue.contains("SYS_GUID()") || defaultValue.contains("SYSDATE") || defaultValue.contains("USERENV(\'SESSIONID\')")) { |
109 |
0
|
return true; |
110 |
|
} |
111 |
0
|
return false; |
112 |
|
} |
113 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.21 |
|
114 |
0
|
@Override... |
115 |
|
public Long getSequenceNextVal(Connection con, String schema, String sequenceName) { |
116 |
0
|
try { |
117 |
0
|
PreparedStatement ps = con.prepareStatement("SELECT last_number FROM all_sequences WHERE sequence_owner = ? AND sequence_name = ?"); |
118 |
0
|
Long nextVal = 0L; |
119 |
0
|
ps.setString(1, schema.toUpperCase()); |
120 |
0
|
ps.setString(2, sequenceName.toUpperCase()); |
121 |
0
|
ResultSet rs = ps.executeQuery(); |
122 |
0
|
if (rs.next()) { |
123 |
0
|
nextVal = rs.getLong(1); |
124 |
|
} |
125 |
0
|
rs.close(); |
126 |
0
|
ps.close(); |
127 |
0
|
return nextVal; |
128 |
|
} catch (SQLException ex) { |
129 |
0
|
System.err.println("Unable to extract sequence definition: " + schema + "." + sequenceName); |
130 |
0
|
ex.printStackTrace(); |
131 |
0
|
return 0L; |
132 |
|
} |
133 |
|
} |
134 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 3 |
Complexity Density: 0.21 |
|
135 |
0
|
@Override... |
136 |
|
public String getViewDefinition(Connection con, String schema, String viewName) { |
137 |
0
|
try { |
138 |
0
|
PreparedStatement ps = con.prepareStatement("SELECT text FROM all_views WHERE owner = ? AND view_name = ?"); |
139 |
0
|
String definition = ""; |
140 |
0
|
ps.setString(1, schema.toUpperCase()); |
141 |
0
|
ps.setString(2, viewName.toUpperCase()); |
142 |
0
|
ResultSet rs = ps.executeQuery(); |
143 |
0
|
if (rs.next()) { |
144 |
0
|
definition = rs.getString(1); |
145 |
|
} |
146 |
0
|
rs.close(); |
147 |
0
|
ps.close(); |
148 |
0
|
return definition; |
149 |
|
} catch (SQLException ex) { |
150 |
0
|
System.err.println("Unable to extract view definition: " + schema + "." + viewName); |
151 |
0
|
ex.printStackTrace(); |
152 |
0
|
return ""; |
153 |
|
} |
154 |
|
} |
155 |
|
|
156 |
|
} |