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);
}
}
}
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);
}
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);
}
}
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);
}
}
}
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;
}
Aggregations