Module bus.mapper

Interface Mapper<T,I extends Serializable>

Type Parameters:
T - 实体类类型
I - 主键类型
All Superinterfaces:
BasicMapper<T,I>, ClassMapper<T>, ConditionMapper<T,Condition<T>>, CursorMapper<T,Condition<T>>, EntityMapper<T,I>, Marker

public interface Mapper<T,I extends Serializable> extends BasicMapper<T,I>, Marker
自定义 Mapper 接口示例,基于主键自增重写了 insert 方法,主要用于展示用法。

在使用 Oracle 或其他数据库时,可通过 @SelectKey 注解自定义主键生成逻辑。

Since:
Java 17+
Author:
Kimi Liu
  • Method Details

    • insert

      @Lang(Caching.class) @Options(useGeneratedKeys=true, keyProperty="id") @InsertProvider(type=EntityProvider.class, method="insert") <S extends T> int insert(S entity)
      保存实体,假设主键自增且名称为 id。

      此方法为示例,可在自定义接口中以相同方式覆盖父接口配置。

      Specified by:
      insert in interface EntityMapper<T,I extends Serializable>
      Type Parameters:
      S - 实体类的子类型
      Parameters:
      entity - 实体对象
      Returns:
      1 表示成功,0 表示失败
    • insertSelective

      @Lang(Caching.class) @Options(useGeneratedKeys=true, keyProperty="id") @InsertProvider(type=EntityProvider.class, method="insertSelective") <S extends T> int insertSelective(S entity)
      保存实体中非空字段,假设主键自增且名称为 id。

      此方法为示例,可在自定义接口中以相同方式覆盖父接口配置。

      Specified by:
      insertSelective in interface EntityMapper<T,I extends Serializable>
      Type Parameters:
      S - 实体类的子类型
      Parameters:
      entity - 实体对象
      Returns:
      1 表示成功,0 表示失败