All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.dbflute.dbway.WayOfSybase Maven / Gradle / Ivy

There is a newer version: 1.2.8
Show newest version
/*
 * Copyright 2014-2023 the original author or authors.
 *
 * 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.
 */
package org.dbflute.dbway;

import java.io.Serializable;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.dbflute.dbway.topic.OnQueryStringConnector;

/**
 * The DB-way of Sybase.
 * @author jflute
 */
public class WayOfSybase implements DBWay, Serializable {

    // ===================================================================================
    //                                                                          Definition
    //                                                                          ==========
    /** The serial version UID for object serialization. (Default) */
    private static final long serialVersionUID = 1L;

    protected static final List _originalWildCardList = Arrays.asList("[", "]");

    // ===================================================================================
    //                                                                        Sequence Way
    //                                                                        ============
    public String buildSequenceNextValSql(String sequenceName) {
        return null;
    }

    // ===================================================================================
    //                                                                       Identity Info
    //                                                                       =============
    public String getIdentitySelectSql() {
        return "select @@identity";
    }

    public String buildIdentityDisableSql(String tableSqlName) {
        return buildIdentityOnOffSql(tableSqlName, true);
    }

    public String buildIdentityEnableSql(String tableSqlName) {
        return buildIdentityOnOffSql(tableSqlName, false);
    }

    protected String buildIdentityOnOffSql(String tableSqlName, boolean insertOn) {
        final String settingValue = (insertOn ? tableSqlName : "");
        return "set temporary option identity_insert = '" + settingValue + "'";
    }

    // ===================================================================================
    //                                                                         SQL Support
    //                                                                         ===========
    public boolean isBlockCommentSupported() {
        return true;
    }

    public boolean isLineCommentSupported() {
        return true;
    }

    // ===================================================================================
    //                                                                        JDBC Support
    //                                                                        ============
    public boolean isScrollableCursorSupported() {
        return true;
    }

    // ===================================================================================
    //                                                                 LikeSearch WildCard
    //                                                                 ===================
    @SuppressWarnings("unchecked")
    public List getOriginalWildCardList() {
        return Collections.EMPTY_LIST;
        // The original wild-cards '[' and ']' of Sybase
        // have an original escape way, so DBFlute cannot
        // handle them
        //return _originalWildCardList;
    }

    // ===================================================================================
    //                                                                    String Connector
    //                                                                    ================
    public OnQueryStringConnector getStringConnector() {
        return STANDARD_STRING_CONNECTOR;
    }

    // ===================================================================================
    //                                                                   SQLException Info
    //                                                                   =================
    public boolean isUniqueConstraintException(String sqlState, Integer errorCode) {
        return "QGA03".equals(sqlState);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy