With jOOQ, what you can do is this:
-- Both "1" should in fact be the same value SELECT 1 FROM TABLE WHERE TABLE.COL < 1 -- Both "2" should in fact be the same value SELECT 2 FROM TABLE WHERE TABLE.COL < 2
As a jOOQ developer, you’re directly manipulating your SQL statement’s AST. Nothing keeps you from turning that AST into a directed graph (beware of cycles, of course), to improve your SQL expressiveness.
// Create a single bind value reference Param<Integer> value = val(1); // And use that reference several times in your query: Select<?> query = DSL.using(configuration) .select(value.as("a")) .from(TABLE) .where(TABLE.COL.lt(value)); assertEquals(1, (int) query.fetchOne("a")); // Now, for the second query, simply change the value value.setValue(2); // ... and execute the query again assertEquals(2, (int) query.fetchOne("a"));