Package org.apache.openjpa.jdbc.sql

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


    private TemporalType getTemporal(FieldMapping field) {
        if (field.getDeclaredTypeCode() != JavaTypes.DATE
            && field.getDeclaredTypeCode() != JavaTypes.CALENDAR)
            return null;

        DBDictionary dict = ((JDBCConfiguration) getConfiguration())
            .getDBDictionaryInstance();
        int def = dict.getJDBCType(field.getTypeCode(), false);
        for (Column col : (List<Column>) field.getValueInfo().getColumns()) {
            if (col.getType() == def)
                continue;
            switch (col.getType()) {
                case Types.DATE:
View Full Code Here


    private TemporalType getTemporal(FieldMapping field) {
        if (field.getDeclaredTypeCode() != JavaTypes.DATE
            && field.getDeclaredTypeCode() != JavaTypes.CALENDAR)
            return null;

        DBDictionary dict = ((JDBCConfiguration) getConfiguration())
            .getDBDictionaryInstance();
        int def = dict.getJDBCType(field.getTypeCode(), false);
        for (Column col : (List<Column>) field.getValueInfo().getColumns()) {
            if (col.getType() == def)
                continue;
            switch (col.getType()) {
                case Types.DATE:
View Full Code Here

    }

    public void appendTo(Select sel, ExpContext ctx, ExpState state,
        SQLBuffer buf, int index) {

        DBDictionary dict = ctx.store.getDBDictionary();
        String func = dict.toUpperCaseFunction;
        dict.assertSupport(func != null, "ToUpperCaseFunction");
        func = dict.getCastFunction(getValue(), func);

        int idx = func.indexOf("{0}");
        buf.append(func.substring(0, idx));
        getValue().appendTo(sel, ctx, state, buf, index);
        buf.append(func.substring(idx + 3));
View Full Code Here

        SQLBuffer sql, int index) {
        BinaryOpExpState bstate = (BinaryOpExpState) state;
        _val1.calculateValue(sel, ctx, bstate.state1, null, null);
        _val2.calculateValue(sel, ctx, bstate.state2, null, null);

        DBDictionary dict = ctx.store.getDBDictionary();
        String func = dict.concatenateFunction;
        dict.assertSupport(func != null, "ConcatenateFunction");
        int part1idx = func.indexOf("{0}");
        int part2idx = func.indexOf("{1}");
        String part1 = func.substring(0, Math.min(part1idx, part2idx));
        String part2 = func.substring(Math.min(part1idx, part2idx) + 3,
            Math.max(part1idx, part2idx));
View Full Code Here

                boolean agg = exps.isAggregate();
                boolean candidate = ProjectionExpressionVisitor.
                    hasCandidateProjections(exps.projections);
                if (agg || (candidate
                    && (exps.distinct & exps.DISTINCT_TRUE) == 0)) {
                    DBDictionary dict = ctx.store.getDBDictionary();
                    dict.assertSupport(dict.supportsSubselect,
                        "SupportsSubselect");

                    Select inner = sel;
                    sel = ctx.store.getSQLFactory().newSelect();
                    sel.setParent(parent, alias);
View Full Code Here

    }

    public void appendTo(Select sel, ExpContext ctx, ExpState state,
        SQLBuffer buf, int index) {

        DBDictionary dict = ctx.store.getDBDictionary();
        String func = dict.toLowerCaseFunction;
        dict.assertSupport(func != null, "ToLowerCaseFunction");
        func = dict.getCastFunction(getValue(), func);

        int idx = func.indexOf("{0}");
        buf.append(func.substring(0, idx));
        getValue().appendTo(sel, ctx, state, buf, index);
        buf.append(func.substring(idx + 3));
View Full Code Here

        return 1;
    }

    public void appendTo(Select sel, ExpContext ctx, ExpState state,
        SQLBuffer sql, int index) {
        DBDictionary dict = ctx.store.getDBDictionary();
        String func;
        if (_where == null) {
            func = dict.trimBothFunction;
            dict.assertSupport(func != null, "TrimBothFunction");
        } else if (_where.booleanValue()) {
            func = dict.trimLeadingFunction;
            dict.assertSupport(func != null, "TrimLeadingFunction");
        } else {
            func = dict.trimTrailingFunction;
            dict.assertSupport(func != null, "TrimTrailingFunction");
        }       
        func = dict.getCastFunction(_val, func);
       
        int fromPart = func.indexOf("{0}");
        int charPart = func.indexOf("{1}");
        if (charPart == -1)
            charPart = func.length();
        String part1 = func.substring(0, Math.min(fromPart, charPart));
        String part2 = func.substring(Math.min(fromPart, charPart) + 3,
            Math.max(fromPart, charPart));
        String part3 = null;
        if (charPart != func.length())
            part3 = func.substring(Math.max(fromPart, charPart) + 3);

        TrimExpState tstate = (TrimExpState) state;
        sql.append(part1);
        if (fromPart < charPart)
            _val.appendTo(sel, ctx, tstate.valueState, sql, 0);
        else
            _trimChar.appendTo(sel, ctx, tstate.charState, sql, 0);
        sql.append(part2);

        if (charPart != func.length()) {
            if (fromPart > charPart)
                _val.appendTo(sel, ctx, tstate.valueState, sql, 0);
            else
                _trimChar.appendTo(sel, ctx, tstate.charState, sql, 0);
            sql.append(part3);
        } else {
            // since the trim statement did not specify the token for
            // where to specify the trim char (denoted by "{1}"),
            // we do not have the ability to trim off non-whitespace
            // characters; throw an exception when we attempt to do so
            if (!(_trimChar instanceof Const) || String.valueOf(((Const)
                _trimChar).getValue(ctx,tstate.charState)).trim().length() != 0)
                dict.assertSupport(false, "TrimNonWhitespaceCharacters");
        }
    }
View Full Code Here

                getDBDictionary().searchStringEscape);
    }

    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

        _cast = type;
    }

    public void appendTo(Select sel, ExpContext ctx, ExpState state,
        SQLBuffer buf, int index) {
        DBDictionary dict = ctx.store.getDBDictionary();
        String func = dict.stringLengthFunction;
        dict.assertSupport(func != null, "StringLengthFunction");
        func = dict.getCastFunction(getValue(), func);
       
        int idx = func.indexOf("{0}");
        buf.append(func.substring(0, idx));
        getValue().appendTo(sel, ctx, state, buf, index);
        buf.append(func.substring(idx + 3));
View Full Code Here

            }
           
            if (xmlTypeClass != null
                && StringUtils.isEmpty(pcols[i].columnDefinition())
                && fm.getDeclaredType().isAnnotationPresent(xmlTypeClass)) {
                DBDictionary dict = ((MappingRepository) getRepository())
                    .getDBDictionary();
                if (dict.supportsXMLColumn)
                    // column maps to xml type
                    ((Column) cols.get(i)).setTypeName(dict.xmlTypeName);
            }
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.