Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/**********************************************************************
Copyright (c) 2009 Anton Troshin. All rights reserved.
Licensed 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.
Contributors:
**********************************************************************/
package org.datanucleus.store.rdbms.adapter;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.sql.DatabaseMetaData;
import java.sql.JDBCType;
import org.datanucleus.ClassLoaderResolver;
import org.datanucleus.identity.DatastoreId;
import org.datanucleus.plugin.PluginManager;
import org.datanucleus.store.rdbms.identifier.IdentifierFactory;
import org.datanucleus.store.rdbms.key.CandidateKey;
import org.datanucleus.store.rdbms.key.ForeignKey;
import org.datanucleus.store.rdbms.key.Index;
import org.datanucleus.store.rdbms.table.Column;
import org.datanucleus.store.rdbms.table.Table;
import org.datanucleus.util.StringUtils;
/**
* Provides methods for adapting SQL language elements to the Oracle Times Ten database
*/
public class TimesTenAdapter extends BaseDatastoreAdapter
{
/**
* A string containing the list of TimesTen reserved keywords
*/
public static final String RESERVED_WORDS =
"AGING, CROSS, GROUP," +
"ALL, CURRENT_SCHEMA, HAVING," +
"ANY, CURRENT_USER, INNER," +
"AS, CURSOR, INT," +
"BETWEEN, DATASTORE_OWNER, INTEGER," +
"BIGINT, DATE, INTERSECT," +
"BINARY, DEC, INTERVAL," +
"BINARY_DOUBLE_INFINITY, DECIMAL, INTO," +
"BINARY_DOUBLE_NAN, DEFAULT, IS," +
"BINARY_FLOAT_INFINITY, DESTROY, JOIN," +
"BINARY_FLOAT_NAN, DISTINCT, LEFT," +
"CASE, DOUBLE, LIKE," +
"CHAR, FIRST, LONG," +
"CHARACTER, FLOAT, MINUS," +
"COLUMN, FOR, NATIONAL," +
"CONNECTION, FOREIGN, NCHAR," +
"CONSTRAINT, FROM, NO," +
"NULL, RIGHT, TINYINT," +
"NUMERIC, ROWNUM, TT_SYSDATE," +
"NVARCHAR, ROWS, UNION," +
"ON, SELECT, UNIQUE," +
"ORA_SYSDATE, SELF, UPDATE," +
"ORDER, SESSION_USER, USER," +
"PRIMARY, SET, USING," +
"PROPAGATE, SMALLINT, VARBINARY," +
"PUBLIC, SOME, VARCHAR," +
"READONLY, SYSDATE, VARYING," +
"REAL, SYSTEM_USER, WHEN," +
"RETURN, TIME, WHERE";
/**
* Constructor.
* Overridden so we can add on our own list of NON SQL92 reserved words
* which is returned incorrectly with the JDBC driver.
* @param metadata MetaData for the DB
*/
public TimesTenAdapter(DatabaseMetaData metadata)
{
super(metadata);
reservedKeywords.addAll(StringUtils.convertCommaSeparatedStringToSet(RESERVED_WORDS));
supportedOptions.remove(DEFERRED_CONSTRAINTS);
supportedOptions.add(UNIQUE_IN_END_CREATE_STATEMENTS);
supportedOptions.remove(CHECK_IN_CREATE_STATEMENTS);
supportedOptions.remove(NULLS_KEYWORD_IN_COLUMN_OPTIONS);
supportedOptions.remove(ANSI_JOIN_SYNTAX);
supportedOptions.remove(FK_DELETE_ACTION_NULL);
supportedOptions.remove(FK_DELETE_ACTION_CASCADE);
supportedOptions.remove(FK_DELETE_ACTION_DEFAULT);
supportedOptions.remove(FK_DELETE_ACTION_RESTRICT);
supportedOptions.remove(FK_UPDATE_ACTION_DEFAULT);
supportedOptions.remove(FK_UPDATE_ACTION_RESTRICT);
supportedOptions.remove(FK_UPDATE_ACTION_NULL);
supportedOptions.remove(FK_UPDATE_ACTION_CASCADE);
supportedOptions.remove(TX_ISOLATION_READ_UNCOMMITTED);
supportedOptions.remove(TX_ISOLATION_REPEATABLE_READ);
supportedOptions.remove(TX_ISOLATION_NONE);
}
@Override
public String getVendorID()
{
return "timesten";
}
/**
* Returns the appropriate SQL to add a candidate key to its table.
* It should return something like:
*
* ALTER TABLE FOO ADD CONSTRAINT FOO_CK (BAZ)
* ALTER TABLE FOO ADD (BAZ)
*
*
* @param ck An object describing the candidate key.
* @param factory Identifier factory
* @return The text of the SQL statement.
*/
public String getAddCandidateKeyStatement(CandidateKey ck, IdentifierFactory factory)
{
Index idx = new Index(ck);
idx.setName(ck.getName());
return getCreateIndexStatement(idx, factory);
}
/**
* Accessor for the SQL statement to add a column to a table.
*
* @param table The table
* @param col The column
* @return The SQL necessary to add the column
*/
public String getAddColumnStatement(Table table, Column col)
{
String stmnt = super.getAddColumnStatement(table, col);
// Add non-nullable column has not been implemented in TimesTen
return stmnt.replaceAll("NOT NULL", "" );
}
/**
* Returns the appropriate SQL to add a foreign key to its table.
* It should return something like:
*