kotlin-exposed-patterns
JetBrains Exposed ORM patterns, including DSL queries, DAO patterns, transactions, HikariCP connection pooling, Flyway migrations, and repository patterns.
Translation reviewedRead the original Chinese text
JetBrains Exposed ORM 模式,包括 DSL 查询、DAO 模式、事务、HikariCP 连接池、Flyway 迁移和仓库模式。
Target: Target not categorized. Automatically collected · unverified.
Excerpt from the author’s documentation
Extracted from a fixed version of SKILL.md in its original language. This is the author’s documentation; installation, compatibility and runtime results have not been verified by this site.
Read the original Chinese text
Topics in the source
- Kotlin Exposed 模式
- 何时使用
- 工作原理
- 示例
- DSL 查询
- DAO 实体用法
- HikariCP 配置
- 数据库设置
使用 JetBrains Exposed ORM 进行数据库访问的全面模式,包括 DSL 查询、DAO、事务以及生产就绪的配置。 使用 Exposed 设置数据库访问 使用 Exposed DSL 或 DAO 编写 SQL 查询 使用 HikariCP 配置连接池 使用 Flyway 创建数据库迁移 使用 Exposed 实现仓储模式 处理 JSON 列和复杂查询 Exposed 提供两种查询风格:用于直接类似 SQL 表达式的 DSL 和用于实体生命周期管理的 DAO。HikariCP 通过 HikariConfig 配置来管理可重用的数据库连接池。Flyway 在启动时运行版本化的 SQL 迁移脚本以保持模式同步。所有数据库操作都在 newSuspendedTransaction 块内运行,以确保协程安全和原子性。仓储模式将 Exposed 查询包装在接口之后,使业务逻辑与数据层解耦,并且测试可以使用内存中的 H2 数据库。 | 模式 | 描述 | |---------|-------------| | object Table : UUIDTable("name") | 定义具有 UUID 主键的表 | | newSuspendedTransaction { } | 协程安全的事务块 | | Table.selectAll().where { } | 带条件的查询 | | Table.insertAndGetId { } | 插入并返回生成的 ID | | Table.update({ condition }) { } | 更新匹配的行 | | Table.deleteWhere { } | 删除匹配的行 | | Table.batchInsert(items) { } | 高效的批量插入 | | innerJoin / leftJoin | 连接表 | | orderBy / limit / offset | 排序和分页 | | count() / sum() / avg() | 聚合函数 | 记住:对于简单查询使用 DSL 风格,当需要实体生命周期管理时使用 DAO 风格。始终使用 newSuspendedTransaction 以获得协程支持,并将数据库操作包装在仓储接口之后以提高可测试性。
- Source repository
- affaan-m/ECC
- Source file
- docs/zh-CN/skills/kotlin-exposed-patterns/SKILL.md
- Fixed revision
- d2ef2680594f9a17526a6e1a2e18b3d242c5d17b
Sources and evidence
This record was collected automatically. Its documentation, suitability and runtime behavior have not been manually verified.
Author: affaan-m/ECC · original repository metadata. Documentation review: Not reviewed. Last source check: 2026-11-09T15:01:42.398Z.
Categories are inferred from names, descriptions and paths. They do not establish compatibility.
License and attribution
MIT. Third-party content and copyright remain with their authors. Refer to the original license and terms.
Original license ↗Synchronization, copying and user-reported success do not mark a resource as runtime-tested.
Limitations and notes
- Collecting metadata does not mean this site has installed, adapted, runtime-tested or security-reviewed the resource.