[英]How to “SELECT SQL_NO_CACHE” using JOOQ?
I tried to find a documentation for it, but failed. 我试图为其找到文档,但失败了。 Anyone knows? 有谁知道?
There are several ways to add MySQL-style hints to jOOQ queries: 有几种方法可以向jOOQ查询添加MySQL风格的提示:
.hint()
使用.hint()
jOOQ allows for passing "hints" to SELECT
statements via the .hint()
method as explained here in the manual: jOOQ允许通过.hint()
方法将“提示”传递给SELECT
语句,如本手册中所述:
http://www.jooq.org/doc/latest/manual/sql-building/sql-statements/select-statement/oracle-hints http://www.jooq.org/doc/latest/manual/sql-building/sql-statements/select-statement/oracle-hints
Applying the SQL_NO_CACHE
hint to the example given in the manual, you'd get: 将SQL_NO_CACHE
提示应用于手册中给出的示例,您将获得:
DSL.using(configuration)
.select(field1, field2)
.hint("SQL_NO_CACHE")
.from(table1)
.fetch();
You could use plain SQL to tweak the first field in your SELECT
clause to contain the hint using DSL.field(String)
. 您可以使用普通SQL来调整SELECT
子句中的第一个字段,以使用DSL.field(String)
包含提示。 Eg 例如
DSL.using(configuration)
.select(DSL.field("SQL_NO_CACHE {0}", field1.getDataType(), field1), field2)
.from(table1)
.fetch();
ExecuteListener
or VisitListener
使用ExecuteListener
或VisitListener
You could inject an ExecuteListener
or a VisitListener
into your configuration in order to transform all relevant SQL query strings to contain the hint right after the SELECT
keyword. 您可以将ExecuteListener
或VisitListener
注入配置中,以转换所有相关的SQL查询字符串以在SELECT
关键字之后包含提示。 This will probably be a bit of overkill in your case, but it's worth mentioning this as an option to this kind of problem. 在您的情况下,这可能有点矫over过正,但是值得一提的是,它可以解决此类问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.