This is experimental functionality, and as such subject to change. Use at your own risk!
Trivial condition
Applies to ❌ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
The SPI methods handling these events are trivialCondition()
. This diagnostic depends on the transform patterns feature.
This problem appears with JDBC, jOOQ or with any ORM. A predicate of arbitrary complexity can sometimes be reduced to a simple TRUE or FALSE condition.
Why is it bad?
A trivial condition is bad for your application for multiple reasons:
- It could just be a typo (e.g. a
JOIN
predicate of the formA.ID = A.ID
instead ofA.ID = B.ID
), in case of which it's simply wrong. - The redundant predicate might be a subtle cause for duplicate statements.
An example is given here:
// A custom DiagnosticsListener SPI implementation class TrivialCondition implements DiagnosticsListener { @Override public void trivialCondition(DiagnosticsContext ctx) { System.out.println("Trivial condition: " + ctx.part()); } }
And then:
// Configuration is configured with the target DataSource, SQLDialect, etc. for instance Oracle. try (Connection c = DSL.using(configuration.derive(new TrivialCondition())) .diagnosticsConnection(); Statement s = c.createStatement()) { try (ResultSet rs = s.executeQuery("SELECT * FROM author WHERE id = id")) { // .. } }
Feedback
Do you have any feedback about this page? We'd love to hear it!