@Override public void renderStart(ExecuteContext ctx) { if (ctx.query() instanceof Select) { // Operate on jOOQ's internal query model SelectQuery<?> select = null; // Check if the query was constructed using the "model" API if (ctx.query() instanceof SelectQuery) { select = (SelectQuery<?>) ctx.query(); } // Check if the query was constructed using the DSL API else if (ctx.query() instanceof SelectFinalStep) { select = ((SelectFinalStep<?>) ctx.query()).getQuery(); } if (select != null) { // Use a more appropriate predicate expression // to form more generic predicates which work on all tables select.addConditions(EMPLOYEE.SECURITY.in(1, 2)); } } }
@Override public void fetchEnd(ExecuteContext ctx) { super.fetchEnd(ctx); Pair<Long, Integer> stopWatchIntegerPair = timing.get(ctx.query().toString()); long duration = System.nanoTime() - stopWatchIntegerPair.getValue0(); timing.put(ctx.query().toString(), new Pair<>(duration, ctx.result().size())); }
@Override public void renderEnd(ExecuteContext ctx) { throw new QueryCollectorSignal(ctx.sql(), ctx.query()); } }
@Override public void renderEnd(ExecuteContext ctx) { throw new QueryCollectorSignal(ctx.sql(), ctx.query()); } }
@Override public void fetchStart(ExecuteContext ctx) { super.start(ctx); StopWatch stopWatch = new StopWatch(); timing.put(ctx.query().toString(), new Pair<>(System.nanoTime(), 0)); stopWatch.start(); } }
@Override public void exception(ExecuteContext ctx) { log.warn( "SQL exception", "Exception while executing meta query: " + (ctx.sqlException() != null ? ctx.sqlException().getMessage() : ctx.exception() != null ? ctx.exception().getMessage() : "No exception available") + "\n\n" + "Please report this bug here: https://github.com/jOOQ/jOOQ/issues/new\n\n```sql\n" + formatted(ctx.query()) + "```\n"); }
@Override public void executeEnd(ExecuteContext ctx) { int s = getLogSlowQueriesAfterSeconds(); if (s <= 0) return; StopWatch watch = (StopWatch) ctx.data("org.jooq.meta.AbstractDatabase.watch"); if (watch.split() > TimeUnit.SECONDS.toNanos(s)) { watch.splitWarn("Slow SQL"); log.warn( "Slow SQL", "jOOQ Meta executed a slow query (slower than " + s + " seconds, configured by configuration/generator/database/logSlowQueriesAfterSeconds)" + "\n\n" + "Please report this bug here: https://github.com/jOOQ/jOOQ/issues/new\n\n```sql\n" + formatted(ctx.query()) + "```\n", new SQLPerformanceWarning()); } }