Skip to content

[feat] PTC Object: @Ignore 注解、集合 CustomType、事务传播#666

Merged
Bkm016 merged 1 commit intoTabooLib:dev/6.2.3from
FxRayHughes:feat/ptc-object-ignore-field
Feb 14, 2026
Merged

[feat] PTC Object: @Ignore 注解、集合 CustomType、事务传播#666
Bkm016 merged 1 commit intoTabooLib:dev/6.2.3from
FxRayHughes:feat/ptc-object-ignore-field

Conversation

@FxRayHughes
Copy link
Contributor

变更内容

为 database-ptc-object 模块新增三项功能:

1. @ignore 注解

  • 标记字段不参与数据库建表、插入、更新和查询
  • 从数据库读取时使用 Kotlin 声明的默认值
  • 优先级最高,覆盖 @id@key 等其他注解

2. 集合 CustomType(扁平化集合存储)

  • CustomType 接口新增 elementType 属性,标识集合级别的自定义类型
  • 支持将 List/Set/Map 通过自定义序列化逻辑扁平化为单列存储
  • CustomTypeFactory 新增 registeredCollectionTypes 双层 Map 和匹配方法

3. 事务传播(Transaction Propagation)

  • TransactionContext 新增 ThreadLocal<Connection> 跟踪当前线程活跃事务
  • 嵌套 transaction() 自动复用外层事务连接,不提交/不回滚/不关闭
  • ContainerOperatorImpl 的 withConnection()/withTransaction() 检查 ThreadLocal

修改文件

  • Annotations.kt — 新增 @ignore 注解
  • AnalyzedClass.kt / AnalyzedClassMember.kt — 忽略字段分析和默认值填充
  • CustomType.kt / CustomTypeFactory.kt — 集合 CustomType 支持
  • ContainerOperatorImpl.kt — CRUD 过滤 @ignore、扁平化集合序列化、ThreadLocal 连接检查
  • ContainerSQL.kt / ContainerPostgreSQL.kt / ContainerSQLite.kt — 建表逻辑适配
  • PersistentContainer.kt / TransactionContext.kt — 事务传播
  • 新增 3 个单元测试文件

- @ignore 注解:标记字段不参与数据库读写,读取时使用 Kotlin 默认值
- 集合 CustomType:支持 List/Set/Map 通过自定义序列化扁平化为单列存储
- 事务传播:嵌套 transaction() 自动复用外层事务连接,ThreadLocal 跟踪活跃事务
@Bkm016 Bkm016 merged commit 403fb89 into TabooLib:dev/6.2.3 Feb 14, 2026
0 of 2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments