Package org.apache.openjpa.jdbc.sql

Examples of org.apache.openjpa.jdbc.sql.DBDictionary


    }

    public void endConfiguration() {
        buildSequence();

        DBDictionary dict = _conf.getDBDictionaryInstance();
        String format = dict.nextSequenceQuery;
        if (format == null) {
            throw new MetaDataException(_loc.get("no-seq-sql", _seqName));
        }

        String name = dict.getFullName(_seq);
        // Increment step is needed for Firebird which uses non-standard sequence fetch syntax.
        // Use String.valueOf to get rid of possible locale-specific number formatting.
        _select = MessageFormat.format(format, new Object[]{name, String.valueOf(_allocate * _increment)});
       
        type = dict.nativeSequenceType;
View Full Code Here


    protected synchronized void allocateInternal(int additional, JDBCStore store, ClassMapping mapping)
        throws SQLException {
        Connection conn = getConnection(store);
        try {
            if (!alterIncrementBy) {
                DBDictionary dict = _conf.getDBDictionaryInstance();
                // If this fails, we will warn the user at most one time and set _allocated and _increment to 1 so
                // as to not potentially insert records ahead of what the database thinks is the next sequence value.
                if (updateSql(conn, dict.getAlterSequenceSQL(_seq)) == -1) {
                    if (!alreadyLoggedAlterSeqFailure) {
                        Log log = _conf.getLog(OpenJPAConfiguration.LOG_RUNTIME);
                        if (log.isWarnEnabled()) {
                            log.warn(_loc.get("fallback-no-seq-cache", _seqName));
                        }
View Full Code Here

    /**
     * Return the next sequence value.
     */
    private long getSequence(Connection conn)
        throws SQLException {
        DBDictionary dict = _conf.getDBDictionaryInstance();
        PreparedStatement stmnt = null;
        ResultSet rs = null;
        try {
            stmnt = conn.prepareStatement(_select);
            dict.setTimeouts(stmnt, _conf, false);
            rs = stmnt.executeQuery();
            if (rs.next())
                return rs.getLong(1);

            // no row !?
View Full Code Here

                try { stmnt.close(); } catch (SQLException se) {}
        }
    }

    private int updateSql(Connection conn, String sql) throws SQLException {
        DBDictionary dict = _conf.getDBDictionaryInstance();
        PreparedStatement stmnt = null;
        int rc = -1;
        try {
            stmnt = conn.prepareStatement(sql);
            dict.setTimeouts(stmnt, _conf, false);
            rc = stmnt.executeUpdate();
        } catch (Exception e) {
            // tolerate exception when attempting to alter increment,
            // however, caller should check rc and not cache sequence values if rc != -1.
        } finally {
View Full Code Here

     * Append SQL for a sub-select testing whether an inverse object exists
     * for this relation.
     */
    private void testInverseNull(SQLBuffer sql, Select sel, Joins joins,
        boolean empty) {
        DBDictionary dict = field.getMappingRepository().getDBDictionary();
        dict.assertSupport(dict.supportsSubselect, "SupportsSubselect");

        if (field.getIndependentTypeMappings().length != 1)
            throw RelationStrategies.uninversable(field);

        if (empty)
View Full Code Here

        return new MatchesExpression((Val) v1, (Const) v2, single, multi, esc);
    }

    public Subquery newSubquery(ClassMetaData candidate, boolean subs,
        String alias) {
        DBDictionary dict = _type.getMappingRepository().getDBDictionary();
        dict.assertSupport(dict.supportsSubselect, "SupportsSubselect");
        return new SubQ((ClassMapping) candidate, subs, alias);
    }
View Full Code Here

            return new ValueMapDiscriminatorStrategy();
        if (cls.getMappedPCSuperclassMapping() != null)
            return NoneDiscriminatorStrategy.getInstance();
        if (adapting || _defaults.defaultMissingInfo())
            return new ClassNameDiscriminatorStrategy();
        DBDictionary dict = ((JDBCConfiguration) getConfiguration()).
            getDBDictionaryInstance();
        if (dict.joinSyntax == JoinSyntaxes.SYNTAX_TRADITIONAL)
            return NoneDiscriminatorStrategy.getInstance();
        return new SubclassJoinDiscriminatorStrategy();
    }
View Full Code Here

    }

    public void endConfiguration() {
        buildSequence();

        DBDictionary dict = _conf.getDBDictionaryInstance();
        if (_format == null) {
            _format = dict.nextSequenceQuery;
            if (_format == null)
                throw new MetaDataException(_loc.get("no-seq-sql", _seqName));
        }
        if (_tableName == null)
            _tableName = "DUAL";

        String name = dict.getFullName(_seq);
        Object[] subs = (_subTable) ? new Object[]{ name, _tableName }
            : new Object[]{ name };
        _select = MessageFormat.format(_format, subs);
       
        type = dict.nativeSequenceType;
View Full Code Here

    public boolean selectForUpdate(Select sel, int lockLevel) {
        if (lockLevel == LOCK_NONE)
            return false;

        DBDictionary dict = _store.getDBDictionary();
        if (dict.simulateLocking)
            return false;
        dict.assertSupport(dict.supportsSelectForUpdate,
            "SupportsSelectForUpdate");

        if (!sel.supportsLocking()) {
            if (log.isInfoEnabled())
                log.info(_loc.get("cant-lock-on-load",
View Full Code Here

     */
    private void lockRow(OpenJPAStateManager sm, int timeout) {
        // assert that the dictionary supports the "SELECT ... FOR UPDATE"
        // construct; if not, and we the assertion does not throw an
        // exception, then just return without locking
        DBDictionary dict = _store.getDBDictionary();
        if (dict.simulateLocking)
            return;
        dict.assertSupport(dict.supportsSelectForUpdate,
            "SupportsSelectForUpdate");

        Object id = sm.getObjectId();
        ClassMapping mapping = (ClassMapping) sm.getMetaData();
        while (mapping.getJoinablePCSuperclassMapping() != null)
View Full Code Here

TOP

Related Classes of org.apache.openjpa.jdbc.sql.DBDictionary

Copyright © 2018 www.massapicom. 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.