Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jooq aggregate functions

I am trying to use aggregate function like max, min in jOOQ and refering their mannual but I am not understanding their examples that how they created max function and used it in their example. Can you please help me out on this. Please provide simple example if possible.

Problem I am facing
In jOOQ mannual example for aggregate function max is as follows

create.select(max(ID).add(1).as("next_id")).from(T_AUTHOR);

but when I used max in my query I am getting function max is undefined.

like image 280
Sandeep Kumar Avatar asked Aug 10 '12 06:08

Sandeep Kumar


1 Answers

The use of static imports is documented in various places of the jOOQ tutorial and manual. Whenever you see a "standalone function" in the manual, you can safely assume that it was static imported from org.jooq.impl.DSL.

See the example taken from the tutorial:

// For convenience, always static import your generated tables and
// jOOQ functions to decrease verbosity:
import static test.generated.Tables.*;
import static org.jooq.impl.DSL.*;
  • http://www.jooq.org/doc/latest/manual/getting-started/tutorials/jooq-in-7-steps/jooq-in-7-steps-step6/
  • http://www.jooq.org/doc/latest/manual/getting-started/the-manual/

Hence, the example you're trying to run will require that you either

  • static import org.jooq.impl.DSL.max
  • fully qualify DSL.max in your query
like image 65
Lukas Eder Avatar answered Sep 20 '22 19:09

Lukas Eder