From a66639c7f9bf6dd2bc4ba7f497539376f1dbe650 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Sun, 7 Jul 2013 12:54:33 +0200 Subject: [PATCH] [#2619] Add an example ExecuteListener to the manual, showing how UPDATE and DELETE statements without WHERE clause can be aborted --- .../src/main/resources/manual-3.2.xml | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/jOOQ-website/src/main/resources/manual-3.2.xml b/jOOQ-website/src/main/resources/manual-3.2.xml index a9552a51d1..e4a03747ba 100644 --- a/jOOQ-website/src/main/resources/manual-3.2.xml +++ b/jOOQ-website/src/main/resources/manual-3.2.xml @@ -8669,6 +8669,8 @@ bookDao.delete(book);]]>

For convenience and better backwards-compatibility, consider extending instead of implementing this interface.

+ +

Example: Query statistics ExecuteListener

Here is a sample implementation of an ExecuteListener, that is simply counting the number of queries per type that are being executed using jOOQ:

@@ -8732,7 +8734,7 @@ for (ExecuteType type : ExecuteType.values()) { Please read the for more details

-

Writing a custom ExecuteListener for logging

+

Example: Custom Logging ExecuteListener

The following depicts an example of a custom ExecuteListener, which pretty-prints all queries being executed by jOOQ to stdout:

@@ -8777,6 +8779,27 @@ public class PrettyPrinter extends DefaultExecuteListener {

See also the manual's sections about and the for more sample implementations of actual ExecuteListeners.

+ +

Example: Bad query execution ExecuteListener

+

+ You can also use ExecuteListeners to interact with your SQL statements, for instance when you want to check if executed or statements contain a WHERE clause. This can be achieved trivially with the following sample ExecuteListener: +

+ + +

+ You might want to replace the above implementation with a more efficient and more reliable one, of course. +