Interface AutoMapper<E,K>

Type Parameters:
E - The entity mapping to the DB table
K - The key of the table. It can only be a subtype of Number or CharSequence

public interface AutoMapper<E,K>
The auto mapper, inherit this interface to get some basic CRUD methods.
  • Method Details

    • insert

      @InsertProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) int insert(@Param("entity") E entity)
      Insert an entity.
      Parameters:
      entity - The entity to be inserted.
      Returns:
      Inserted count.
    • insertAll

      @InsertProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) int insertAll(@Param("entities") Collection<E> entities)
      Insert multiple entities
      Parameters:
      entities - Entities to be inserted.
      Returns:
      Inserted count.
    • selectById

      @SelectProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) E selectById(@Param("id") K id)
      Select an entity by the ID.
      Parameters:
      id - ID
      Returns:
      Selected entity.
    • selectAllById

      @SelectProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) List<E> selectAllById(@Param("ids") Collection<K> ids)
      Select entities by the ID collection.
      Parameters:
      ids - ID collection.
      Returns:
      Selected entities.
    • selectAllByColumn

      @SelectProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) List<E> selectAllByColumn(@Param("column") String column, @Param("value") Object value)
      Select entities by a column.
      Parameters:
      column - Column name.
      value - The value to be selected of the column.
      Returns:
      Selected entities.
    • selectAll

      @SelectProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) List<E> selectAll()
      Select all entities.
      Returns:
      Selected entities.
    • countAll

      @SelectProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) long countAll()
      Count all entities.
      Returns:
      All entities count.
    • deleteById

      @DeleteProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) int deleteById(@Param("id") K id)
      Delete an entity by ID
      Parameters:
      id - Entity ID.
      Returns:
      Deleted count.
    • deleteAllById

      @DeleteProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) int deleteAllById(@Param("ids") Collection<K> ids)
      Delete entities by the ID collection.
      Parameters:
      ids - ID collection.
      Returns:
      Deleted count.
    • deleteAll

      @DeleteProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) void deleteAll()
      Delete all entities using the SQL truncate table <table_name>.
    • update

      @UpdateProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) int update(@Param("entity") E entity)
      Update an entity by the ID.

      Note: If fields in the entity are passed null values, the column values in DB are updated to be null.

      Parameters:
      entity - The entity to be updated.
      Returns:
      Updated count.
    • updateAll

      default int updateAll(Collection<E> entities)
      Update entities by their ID.

      Note: If fields in the entity are passed null values, the column values in DB are updated to be null.

      Parameters:
      entities - Entities to be updated.
      Returns:
      Updated count.
    • updateSelective

      @UpdateProvider(tech.yanand.flyingmybatis.AutoMapperProvider.class) int updateSelective(@Param("entity") E entity)
      Selectively update an entity by the ID. If a field in entity is passed null value, it will not be updated.
      Parameters:
      entity - The entity to be updated.
      Returns:
      Updated count.
    • updateAllSelective

      default int updateAllSelective(Collection<E> entities)
      Selectively update entities by their ID. If a field in entity is passed null value, it will not be updated.
      Parameters:
      entities - Entities to be updated.
      Returns:
      Updated count.