Hello, There's a short section on optimisation in the manual: http://www.jooq.org/doc/latest/manual/sql-execution/performance-considerations
Essentially it reads: Don't :) (unless you measured stuff and *know* you have a bottleneck). If you still want to generate SQL strings only once, we generally suggest you extract the string and its bind values and execute them via: - DSLContext.fetch() or DSLContext.execute() - JDBC directly - Some other tool You can extract the SQL and bind values using: - Query.getSQL() ( http://www.jooq.org/javadoc/latest/org/jooq/Query.html#getSQL--) - Query.getBindValues() ( http://www.jooq.org/javadoc/latest/org/jooq/Query.html#getBindValues--) As of jOOQ 3.x, Query objects aren't thread safe and must not be used by several threads at the same time. Hope this helps, Lukas 2015-06-01 18:09 GMT+02:00 Robert DiFalco <[email protected]>: > I'm really enjoying using JOOQ but I have a question about static queries > that I use over and over again. > > I'm not sure why I need to parse these every time they are executed > because they never change. I was thinking that in my DAO constructor I > would just create them once with #getSQL and then use ResultQuery with > saved the string. Of course doing that I lose all the type bindings. > > I thought that I should be able to save ResultQuery objects instead and > reuse them but I think (and I'm not sure why) that they are tied to the > connection. Or am I missing something? Is there a way to cache the type > safe queries without any database connection context? > > Thanks! > > -- > You received this message because you are subscribed to the Google Groups > "jOOQ User Group" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "jOOQ User Group" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
