Search in sources :

Example 16 with Configuration

use of org.jooq.Configuration in project jOOQ by jOOQ.

the class LoggerListener method renderEnd.

@Override
public void renderEnd(ExecuteContext ctx) {
    if (log.isDebugEnabled()) {
        Configuration configuration = ctx.configuration();
        String newline = TRUE.equals(configuration.settings().isRenderFormatted()) ? "\n" : "";
        // [#2939] Prevent excessive logging of bind variables only in DEBUG mode, not in TRACE mode.
        if (!log.isTraceEnabled())
            configuration = abbreviateBindVariables(configuration);
        String[] batchSQL = ctx.batchSQL();
        if (ctx.query() != null) {
            // Actual SQL passed to JDBC
            log.debug("Executing query", newline + ctx.sql());
            // [#1278] DEBUG log also SQL with inlined bind values, if
            // that is not the same as the actual SQL passed to JDBC
            String inlined = DSL.using(configuration).renderInlined(ctx.query());
            if (!ctx.sql().equals(inlined))
                log.debug("-> with bind values", newline + inlined);
        } else // [#2987] Log routines
        if (ctx.routine() != null) {
            log.debug("Calling routine", newline + ctx.sql());
            String inlined = DSL.using(configuration).renderInlined(ctx.routine());
            if (!ctx.sql().equals(inlined))
                log.debug("-> with bind values", newline + inlined);
        } else if (!StringUtils.isBlank(ctx.sql())) {
            // [#1529] Batch queries should be logged specially
            if (ctx.type() == ExecuteType.BATCH)
                log.debug("Executing batch query", newline + ctx.sql());
            else
                log.debug("Executing query", newline + ctx.sql());
        } else // [#2532] Log a complete BatchMultiple query
        if (batchSQL.length > 0) {
            if (batchSQL[batchSQL.length - 1] != null)
                for (String sql : batchSQL) log.debug("Executing batch query", newline + sql);
        }
    }
}
Also used : Configuration(org.jooq.Configuration)

Example 17 with Configuration

use of org.jooq.Configuration in project jOOQ by jOOQ.

the class UDTRecordImpl method writeSQL.

@Override
public final void writeSQL(SQLOutput stream) throws SQLException {
    Configuration configuration = localConfiguration();
    Map<Object, Object> data = localData();
    for (Field<?> field : getUDT().fields()) set(configuration, data, stream, field);
}
Also used : Configuration(org.jooq.Configuration) DefaultExecuteContext.localConfiguration(org.jooq.impl.DefaultExecuteContext.localConfiguration)

Example 18 with Configuration

use of org.jooq.Configuration in project jOOQ by jOOQ.

the class UDTRecordImpl method readSQL.

@Override
public final void readSQL(SQLInput stream, String typeName) throws SQLException {
    Configuration configuration = localConfiguration();
    Map<Object, Object> data = localData();
    for (Field<?> field : getUDT().fields()) {
        setValue(configuration, data, stream, field);
    }
}
Also used : Configuration(org.jooq.Configuration) DefaultExecuteContext.localConfiguration(org.jooq.impl.DefaultExecuteContext.localConfiguration)

Example 19 with Configuration

use of org.jooq.Configuration in project jOOQ by jOOQ.

the class RowSubqueryCondition method delegate.

private final QueryPartInternal delegate(Context<?> ctx) {
    final Configuration configuration = ctx.configuration();
    final RenderContext render = ctx instanceof RenderContext ? (RenderContext) ctx : null;
    SQLDialect family = configuration.dialect().family();
    // [#3505] TODO: Emulate this where it is not supported
    if (rightQuantified != null) {
        return new Native();
    } else // predicates with row value expressions and subqueries:
    if (asList(H2, HSQLDB, MARIADB, MYSQL, POSTGRES).contains(family)) {
        return new Native();
    } else // [#2395] All other configurations have to be emulated
    {
        String table = render == null ? "t" : render.nextAlias();
        List<String> names = new ArrayList<String>();
        for (int i = 0; i < left.size(); i++) {
            names.add(table + "_" + i);
        }
        Field<?>[] fields = new Field[names.size()];
        for (int i = 0; i < fields.length; i++) {
            fields[i] = field(name(table, names.get(i)));
        }
        Condition condition;
        switch(comparator) {
            case GREATER:
                condition = ((RowN) left).gt(row(fields));
                break;
            case GREATER_OR_EQUAL:
                condition = ((RowN) left).ge(row(fields));
                break;
            case LESS:
                condition = ((RowN) left).lt(row(fields));
                break;
            case LESS_OR_EQUAL:
                condition = ((RowN) left).le(row(fields));
                break;
            case IN:
            case EQUALS:
            case NOT_IN:
            case NOT_EQUALS:
            default:
                condition = ((RowN) left).eq(row(fields));
                break;
        }
        Select<Record> subselect = select().from(right.asTable(table, names.toArray(EMPTY_STRING))).where(condition);
        switch(comparator) {
            case NOT_IN:
            case NOT_EQUALS:
                return (QueryPartInternal) notExists(subselect);
            default:
                return (QueryPartInternal) exists(subselect);
        }
    }
}
Also used : Condition(org.jooq.Condition) RenderContext(org.jooq.RenderContext) RowN(org.jooq.RowN) Configuration(org.jooq.Configuration) SQLDialect(org.jooq.SQLDialect) Select(org.jooq.Select) QuantifiedSelect(org.jooq.QuantifiedSelect) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) List(java.util.List)

Example 20 with Configuration

use of org.jooq.Configuration in project jOOQ by jOOQ.

the class Mock method result.

/**
     * Wrap a record in a result.
     */
static final Result<?> result(Record data) {
    Configuration configuration = data instanceof AttachableInternal ? ((AttachableInternal) data).configuration() : new DefaultConfiguration();
    Result<Record> result = using(configuration).newResult(data.fields());
    result.add(data);
    return result;
}
Also used : Configuration(org.jooq.Configuration) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) DefaultConfiguration(org.jooq.impl.DefaultConfiguration) Record(org.jooq.Record) AttachableInternal(org.jooq.AttachableInternal)

Aggregations

Configuration (org.jooq.Configuration)21 AttachableInternal (org.jooq.AttachableInternal)4 StringUtils.defaultString (org.jooq.tools.StringUtils.defaultString)4 OffsetDateTime (java.time.OffsetDateTime)3 ArrayList (java.util.ArrayList)3 List (java.util.List)3 ExecuteContext (org.jooq.ExecuteContext)3 Query (org.jooq.Query)3 BigDecimal (java.math.BigDecimal)2 BigInteger (java.math.BigInteger)2 Date (java.sql.Date)2 Time (java.sql.Time)2 LocalDate (java.time.LocalDate)2 LocalDateTime (java.time.LocalDateTime)2 LocalTime (java.time.LocalTime)2 OffsetTime (java.time.OffsetTime)2 SQLDialect (org.jooq.SQLDialect)2 DefaultExecuteContext.localConfiguration (org.jooq.impl.DefaultExecuteContext.localConfiguration)2 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 ImmutableSet (com.google.common.collect.ImmutableSet)1