T - 主表实体类型C - 子表实体类型public interface KeyMapping<T,C>
通常用于动态 SQL 查询中,将主表记录与子表记录进行关联, 并在结果中以集合方式呈现(如将多个子记录封装进主记录的一个字段中)。
| Modifier and Type | Method and Description |
|---|---|
FieldFn<C,?> |
childKey()
获取子表用于关联的键(通常是外键字段)。
|
static <T,C> KeyMapping<T,C> |
of(FieldFn<T,?> parentKey,
FieldFn<C,?> childKey)
创建一个 KeyMapping 映射对象,用于建立主表与子表之间的键值对应关系。
|
FieldFn<T,?> |
parentKey()
获取主表用于关联的键(通常是主键字段)。
|
FieldFn<T,?> parentKey()
static <T,C> KeyMapping<T,C> of(FieldFn<T,?> parentKey, FieldFn<C,?> childKey)
例如:
KeyMapping.of(Category::getCategoryId, Product::getCategoryId)
用于将 Category 的 categoryId 与 Product 的 categoryId 建立一对多关系。T - 主表类型C - 子表类型parentKey - 主表键字段引用childKey - 子表键字段引用Copyright © 2024–2025 Dynamic-SQL. All rights reserved.