Package org.jpox.store.rdbms.adapter

Source Code of org.jpox.store.rdbms.adapter.PointbaseAdapter

/**********************************************************************
Copyright (c) 2004 Andy Jefferson and others. 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.jpox.store.rdbms.adapter;

import java.sql.DatabaseMetaData;
import java.sql.Types;

import org.jpox.store.mapped.DatastoreContainerObject;
import org.jpox.store.mapped.DatastoreIdentifier;
import org.jpox.store.mapped.expression.LogicSetExpression;
import org.jpox.store.mapped.expression.QueryExpression;
import org.jpox.store.mapped.expression.TableExprAsJoins;
import org.jpox.store.rdbms.typeinfo.TypeInfo;

/**
* Provides methods for adapting SQL language elements to the Pointbase database.
*
* @version $Revision: 1.14 $
*/
public class PointbaseAdapter extends DatabaseAdapter
{
    /**
     * Constructor.
     * @param metadata MetaData for the Database
     */
    public PointbaseAdapter(DatabaseMetaData metadata)
    {
        super(metadata);

        // Add on any missing JDBC types
        // Based on PointbaseAdapter : PointBase version=5.1 ECF build 295, major=5, minor=1, revision=0
        // Driver name=PointBase JDBC Driver, version=5.1 ECF build 295, major=5, minor=1

        //somehow BIGINT is set to 9
        JDBCTypeInfo fromJDBC = (JDBCTypeInfo) typesByTypeNumber.get(new Integer(9));
        if (fromJDBC != null)
        {
            TypeInfo ti = new TypeInfo(fromJDBC.defaultTypeInfo.typeName,
                (short)Types.BIGINT,
                fromJDBC.defaultTypeInfo.precision,
                fromJDBC.defaultTypeInfo.literalPrefix,
                fromJDBC.defaultTypeInfo.literalSuffix,
                fromJDBC.defaultTypeInfo.createParams,
                fromJDBC.defaultTypeInfo.nullable,
                fromJDBC.defaultTypeInfo.caseSensitive,
                fromJDBC.defaultTypeInfo.searchable,
                fromJDBC.defaultTypeInfo.unsignedAttribute,
                fromJDBC.defaultTypeInfo.fixedPrecScale,
                fromJDBC.defaultTypeInfo.autoIncrement,
                fromJDBC.defaultTypeInfo.localTypeName,
                fromJDBC.defaultTypeInfo.minimumScale,
                fromJDBC.defaultTypeInfo.maximumScale,
                fromJDBC.defaultTypeInfo.numPrecRadix);
            addTypeInfo((short)Types.BIGINT, ti, true);
        }

        //somehow BOOLEAN is set to 16
        fromJDBC = (JDBCTypeInfo) typesByTypeNumber.get(new Integer(16));
        if (fromJDBC != null)
        {
            TypeInfo ti = new TypeInfo(fromJDBC.defaultTypeInfo.typeName,
                (short)Types.BOOLEAN,
                fromJDBC.defaultTypeInfo.precision,
                fromJDBC.defaultTypeInfo.literalPrefix,
                fromJDBC.defaultTypeInfo.literalSuffix,
                fromJDBC.defaultTypeInfo.createParams,
                fromJDBC.defaultTypeInfo.nullable,
                fromJDBC.defaultTypeInfo.caseSensitive,
                fromJDBC.defaultTypeInfo.searchable,
                fromJDBC.defaultTypeInfo.unsignedAttribute,
                fromJDBC.defaultTypeInfo.fixedPrecScale,
                fromJDBC.defaultTypeInfo.autoIncrement,
                fromJDBC.defaultTypeInfo.localTypeName,
                fromJDBC.defaultTypeInfo.minimumScale,
                fromJDBC.defaultTypeInfo.maximumScale,
                fromJDBC.defaultTypeInfo.numPrecRadix);
            addTypeInfo((short)Types.BOOLEAN, ti, true);
        }
    }

    /**
     * Accessor for the vendor id.
     * @return The vendor id.
     **/
    public String getVendorID()
    {
        return "pointbase";
    }

    /**
     * Accessor for whether Pointbase supports deferred constraints.
     * @return Whether it supports deferred constraints
     */
    public boolean supportsDeferredConstraints()
    {
        // Pointbase 4.4 certainly doesnt support them
        return false;
    }

    public LogicSetExpression newTableExpression(QueryExpression qs, DatastoreContainerObject table, DatastoreIdentifier rangeVar)
    {
        return new TableExprAsJoins(qs,table,rangeVar);
    }

    /**
     * Accessor for whether boolean comparison is supported in SQL.
     * @return Whether boolean comparison is supported in SQL.
     */
    public boolean supportsBooleanComparison()
    {
        return false;
    }

    /**
     * Returns the precision value to be used when creating string columns of
     * "unlimited" length.  Usually, if this value is needed it is provided in
     * the database metadata ({@link TypeInfo#precision}).  However, for some
     * types in some databases the value must be computed specially.
     * @param typeInfo the typeInfo object for which the precision value is needed.
     * @return  the precision value to be used when creating the column, or -1
     *          if no value should be used.
     */
    public int getUnlimitedLengthPrecisionValue(TypeInfo typeInfo)
    {
        if (typeInfo.dataType == Types.BLOB || typeInfo.dataType == Types.CLOB)
        {
            return 1 << 31;
        }
        else
        {
            return super.getUnlimitedLengthPrecisionValue(typeInfo);
        }
    }
}
TOP

Related Classes of org.jpox.store.rdbms.adapter.PointbaseAdapter

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.