OPENJPA-735: OpenJPA support for SolidDB

git-svn-id: https://svn.apache.org/repos/asf/openjpa/trunk@984222 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Fay Wang 2010-08-10 21:46:29 +00:00
parent c9f58ec243
commit 8cb9f588ff
3 changed files with 104 additions and 0 deletions

View File

@ -215,6 +215,7 @@ public class JDBCConfigurationImpl
"oracle", "org.apache.openjpa.jdbc.sql.OracleDictionary", "oracle", "org.apache.openjpa.jdbc.sql.OracleDictionary",
"pointbase", "org.apache.openjpa.jdbc.sql.PointbaseDictionary", "pointbase", "org.apache.openjpa.jdbc.sql.PointbaseDictionary",
"postgres", "org.apache.openjpa.jdbc.sql.PostgresDictionary", "postgres", "org.apache.openjpa.jdbc.sql.PostgresDictionary",
"soliddb", "org.apache.openjpa.jdbc.sql.SolidDBDictionary",
"sqlserver", "org.apache.openjpa.jdbc.sql.SQLServerDictionary", "sqlserver", "org.apache.openjpa.jdbc.sql.SQLServerDictionary",
"sybase", "org.apache.openjpa.jdbc.sql.SybaseDictionary", "sybase", "org.apache.openjpa.jdbc.sql.SybaseDictionary",
}; };

View File

@ -270,6 +270,8 @@ public class DBDictionaryFactory {
// "testdb2" or something) // "testdb2" or something)
if (prod.indexOf("db2") != -1 || prod.indexOf("as400") != -1) if (prod.indexOf("db2") != -1 || prod.indexOf("as400") != -1)
return dbdictionaryPlugin.unalias("db2"); return dbdictionaryPlugin.unalias("db2");
if (prod.indexOf("soliddb") != -1)
return dbdictionaryPlugin.unalias("soliddb");
// known dbs that we don't support // known dbs that we don't support
if (prod.indexOf("cloudscape") != -1) if (prod.indexOf("cloudscape") != -1)

View File

@ -0,0 +1,101 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.openjpa.jdbc.sql;
import java.util.Arrays;
import org.apache.commons.lang.StringUtils;
import org.apache.openjpa.jdbc.identifier.DBIdentifier;
import org.apache.openjpa.jdbc.schema.Column;
import org.apache.openjpa.jdbc.schema.PrimaryKey;
import org.apache.openjpa.jdbc.schema.Table;
import org.apache.openjpa.jdbc.schema.Unique;
/**
* Dictionary for SolidDB database.
*/
public class SolidDBDictionary
extends DBDictionary {
/**
* Sets whether tables are to be located in-memory or on disk.
* Creating in-memory tables should append "STORE MEMORY" to the
* "CREATE TABLE" statement. Creating disk-based tables should
* append "STORE DISK".
*/
public boolean storeIsMemory = true;
public SolidDBDictionary() {
platform = "SolidDB";
bitTypeName = "TINYINT";
blobTypeName = "LONG VARBINARY";
booleanTypeName = "TINYINT";
clobTypeName = "LONG VARCHAR";
allowsAliasInBulkClause = false;
useGetStringForClobs = true;
useSetStringForClobs = true;
reservedWordSet.addAll(Arrays.asList(new String[]{
"BIGINT", "BINARY", "DATE", "TIME",
"TINYINT", "VARBINARY"
}));
}
@Override
public String[] getCreateTableSQL(Table table) {
StringBuilder buf = new StringBuilder();
buf.append("CREATE TABLE ").append(getFullName(table, false)).append(" (");
Column[] cols = table.getColumns();
for (int i = 0; i < cols.length; i++) {
if (i > 0)
buf.append(", ");
buf.append(getDeclareColumnSQL(cols[i], false));
}
PrimaryKey pk = table.getPrimaryKey();
String pkStr;
if (pk != null) {
pkStr = getPrimaryKeyConstraintSQL(pk);
if (!StringUtils.isEmpty(pkStr))
buf.append(", ").append(pkStr);
}
Unique[] unqs = table.getUniques();
String unqStr;
for (int i = 0; i < unqs.length; i++) {
unqStr = getUniqueConstraintSQL(unqs[i]);
if (unqStr != null)
buf.append(", ").append(unqStr);
}
buf.append(") STORE ");
if (storeIsMemory)
buf.append("MEMORY");
else
buf.append("DISK");
return new String[]{ buf.toString() };
}
public String convertSchemaCase(DBIdentifier objectName) {
if (objectName != null && objectName.getName() == null)
return "";
return super.convertSchemaCase(objectName);
}
}