【发布时间】:2019-07-04 02:51:25
【问题描述】:
我正在使用以下 jOOQ 配置:
private fun createConfiguration(dataSource: DataSource, loggerListener: JooqLoggerListener): Configuration {
return DefaultConfiguration()
.set(dataSource)
.set(SQLDialect.POSTGRES_10)
.set(DefaultExecuteListenerProvider(loggerListener))
.set(Settings()
.withExecuteLogging(false) // We already use the custom [JooqLoggerListener].
.withParamType(ParamType.NAMED)
.withRenderFormatted(true)
.withRenderKeywordStyle(RenderKeywordStyle.UPPER)
.withRenderNameStyle(RenderNameStyle.LOWER))
}
除withParamType(ParamType.NAMED) 外,所有设置均有效。
但是将 SQL 记录在我的自定义 JooqLoggerListener 中,例如:
override fun renderEnd(ctx: ExecuteContext) {
if (logger.isDebugEnabled) {
val configuration = ctx.configuration()
val newline = if (configuration.settings().isRenderFormatted) "\n" else ""
val inlined = DSL.using(configuration).renderInlined(ctx.query())
logger.debug("Executing query:{}{}", newline, ctx.sql())
logger.debug("Executing query (with bind values):{}{}", newline, inlined)
}
}
仍然打印问号:
13:41:47.472 [nioEventLoopGroup-1-3] DEBUG c.e.logging.JooqLoggerListener - Executing query:
SELECT
country.id,
country.alpha2_code,
country.alpha3_code,
country.name,
country.demonym,
country.continent_id
FROM country
WHERE country.id = ?
我本来希望是这样的:
WHERE country.id = :id
我的假设是正确的还是withParamType(ParamType.NAMED) 用于其他用途?
【问题讨论】: