可用版本: Dev (3.21) | 最新 (3.20) | 3.19 | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11

DSLContext API

适用于 ✅ 开源版   ✅ 专业版   ✅ 企业版

DSLContext 引用一个 org.jooq.Configuration,它是一个配置 jOOQ 在执行查询时的行为的对象(更多详情请参见 SQL 执行)。与静态 DSL 不同,DSLContext 允许创建已经“配置”好并准备好执行的 SQL 语句

流畅地创建 DSLContext 对象

DSLContext 对象可以从 DSL 类型流畅地创建。

// Create it from a pre-existing configuration
DSLContext create = DSL.using(configuration);

// Create it from ad-hoc arguments
DSLContext create = DSL.using(connection, dialect);

如果您没有对预先存在的 Configuration 对象的引用(例如,从 org.jooq.impl.DefaultConfiguration 创建的),各种重载的 DSL.using() 方法将为您创建一个。

Configuration 对象的内容

Configuration 可以提供以下对象

DSLContext 的用法

通过包装一个 Configuration 对象,DSLContext 可以构建 语句,以便稍后执行。这里给出一个例子

// The DSLContext is "configured" with a Connection and a SQLDialect
DSLContext create = DSL.using(connection, dialect);

// This select statement contains an internal reference to the DSLContext's Configuration:
Select<?> select = create.selectOne();

// Using the internally referenced Configuration, the select statement can now be executed:
Result<?> result = select.fetch();

请注意,您不需要保留对 DSLContext 的引用。您也可以内联您的局部变量,并流畅地执行 SQL 语句,例如

// Execute a statement from a single execution chain:
Result<?> result =
DSL.using(connection, dialect)
   .select()
   .from(BOOK)
   .where(BOOK.TITLE.like("Animal%"))
   .fetch();

目录

3.2.1.
SQL 方言
3.2.2.
SQL方言系列
3.2.3.
SQL方言类别
3.2.4.
Connection与DataSource
3.2.5.
自定义数据
3.2.6.
自定义ExecuteListeners
3.2.7.
自定义Unwrappers
3.2.8.
自定义设置
3.2.8.1.
自动附加记录
3.2.8.2.
自动内联绑定值
3.2.8.3.
反斜杠转义
3.2.8.4.
批量大小
3.2.8.5.
计算列激活 (新增)
3.2.8.6.
计算列仿真
3.2.8.7.
诊断连接
3.2.8.8.
诊断日志记录
3.2.8.9.
方言兼容性
3.2.8.10.
脏跟踪 (新增)
3.2.8.11.
美元引号字符串标记
3.2.8.12.
执行日志记录
3.2.8.13.
执行日志记录SQL异常
3.2.8.14.
获取已修剪的CHAR类型 (新增)
3.2.8.15.
获取警告
3.2.8.16.
GROUP_CONCAT配置
3.2.8.17.
标识符样式
3.2.8.18.
隐式连接类型
3.2.8.19.
内联阈值
3.2.8.20.
IN列表填充
3.2.8.21.
解释器配置
3.2.8.22.
JDBC标志
3.2.8.23.
关键字样式
3.2.8.24.
监听器调用顺序
3.2.8.25.
语言环境
3.2.8.26.
映射JPA注解
3.2.8.27.
对象限定
3.2.8.28.
列的对象限定
3.2.8.29.
乐观锁定
3.2.8.30.
参数名称前缀
3.2.8.31.
参数类型
3.2.8.32.
解析器配置
3.2.8.33.
只读列行为
3.2.8.34.
反射缓存
3.2.8.35.
渲染配置
3.2.8.36.
存储时返回所有列
3.2.8.37.
存储时返回计算列
3.2.8.38.
存储时返回DEFAULT列
3.2.8.39.
存储时返回身份值
3.2.8.40.
运行时目录、模式和表映射
3.2.8.41.
存储过程的标量子查询
3.2.8.42.
SEEK子句实现
3.2.8.43.
语句类型
3.2.8.44.
可更新的主键
3.2.9.
线程安全

上一节 : 下一节

反馈

您对此页面有任何反馈吗? 我们很乐意听到!

The jOOQ Logo