Easy-Es Easy-Es
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)

adv display by random ❤️become sponsor
💋Home
  • v2.0.0(current version)
  • What's New

    • What' s New In Easy-Es v2.0.0?
  • history version

    • v1.x.x
  • Upgrade guide

    • Upgrade to 2.x.x instructions
💖Support
  • OS Community
  • Recommend Goods
  • Project PPT (opens new window)
  • Project introduction
  • Project members
  • PR
Join
Customer
  • Doc-Apis (opens new window)
  • Fitness plan automatic generation system (opens new window)
  • Vuepress-theme-vdoing (opens new window)
  • Gitee (opens new window)
  • Github (opens new window)
  • 简体中文 (opens new window)
  • English (opens new window)
  • Quick start

    • Introduction
    • Applicable scene
    • Worry free
    • Avoid pit
    • Quick start
    • Springboot demo
    • Config
    • Annotation
  • Core functions

    • Auto process index
    • CRUD
      • Mapper CRUD interface
        • Insert
        • Parameter Description
        • Delete
        • Parameter Description
        • Update
        • Parameter Description
        • Select
        • Parameter Description
    • Condition constructor
  • Extended function

    • Mixed query
    • Origin query
    • Page
    • Nested
    • Join Parent child
    • Get DSL
  • High-level syntax

    • Field filtering
    • Sort
    • Aggregation
    • Match
    • Weight
    • Highlight
    • Geo
  • Plugin

    • Plugin
  • Other

    • Faq
    • Difference from MP
    • MySQL and EE syntax comparison
    • Update log
    • Update plan
    • Copyright
    • Thanks
  • v1.xDoc
  • Core functions
LaoHan
2023-03-18
目录

CRUD

# Mapper CRUD interface

Description

  • Generic CRUD wrapper [BaseEsMapper](https://gitee.com/dromara/easy-es/blob/master/easy-es-core/src/main/java/cn/easyes/core/conditions/interfaces/BaseEsMapper. java) interface, which automatically resolves the entity-object-relationship mapping for Easy-Es startup and converts it to EE internal object injection container
  • the generic type T is any entity object
  • The insert interface needs to be different from MP. For details, see the insert document below
  • The parameter Serializable is any type of primary key. Easy-Es does not recommend using composite primary key convention. Each index has its own unique id primary key
  • Object Wrapper as conditional constructor
  • For the get and set methods in the entity object T, we recommend that you use the Lombok (opens new window) plug-in to generate, if you use IDEA's built-in plug-in to generate the field names obtained in Lambda style , it will cause some fields named in camel case to fail to obtain the correct field name. For example, there is a field name called eName, the get method generated by Lombok is getEName(), but IDEA generates geteName(), so an error will be reported when the underlying framework parses the field name, and MP also has the same problem.

# Insert

// insert a record
Integer insert(T entity);

// batch insert multiple records
Integer insertBatch(Collection<T> entityList)
1
2
3
4
5
# Parameter Description
Type Parameter Name Description
T entity entity object
Collection<T> entityList collection of entity objects

Tips

  • If the entity you passed in when inserting has an id and the data corresponding to the id already exists, the actual effect of this insert is to update the data corresponding to the id, and the update is not counted in the total number of successful entries returned by the insert interface.
  • When the insert interface as described above triggers the data update logic, the updated fields and globally configured policies (such as NOT_NULL/NOT_EMPTY) will not take effect. If you expect the policy to take effect, you can call the update interface instead of the insert interface
  • After inserting, if you need the id value, you can directly get the id value from the entity. The usage is the same as that in MP. Batch inserting can also directly get the data id after successful insertion from the original object. The above interface returns Integer as the number of successful entries.

# Delete

 // delete by ID
Integer deleteById(Serializable id);

// According to the entity condition, delete the record
Integer delete(LambdaEsQueryWrapper<T> wrapper);

// delete (batch delete according to ID)
Integer deleteBatchIds(Collection<? extends Serializable> idList);
1
2
3
4
5
6
7
8
# Parameter Description
Type Parameter Name Description
Wrapper<T> queryWrapper Entity wrapper class QueryWrapper
Serializable id primary key ID
Collection<? extends Serializable> idList Primary key ID list

# Update

//update according to ID
Integer updateById(T entity);

// batch update by ID
Integer updateBatchByIds(Collection<T> entityList);

// Update records based on dynamic conditions
Integer update(T entity, LambdaEsUpdateWrapper<T> updateWrapper);
1
2
3
4
5
6
7
8
# Parameter Description
Type Parameter Name Description
T entity entity object
Wrapper<T> updateWrapper Entity object encapsulation operation class UpdateWrapper
Collection<T> entityList collection of entity objects

# Select

// get the total
    Long selectCount(LambdaEsQueryWrapper<T> wrapper);
 // query by ID
    T selectById(Serializable id);
// Query (batch query based on ID)
    List<T> selectBatchIds(Collection<? extends Serializable> idList);
// According to the dynamic query conditions, query a record if there are multiple records, an error will be reported
    T selectOne(LambdaEsQueryWrapper<T> wrapper);
    // According to dynamic query conditions, query all records
    List<T> selectList(LambdaEsQueryWrapper<T> wrapper);
1
2
3
4
5
6
7
8
9
10
# Parameter Description
Type Parameter Name Description
Wrapper<T> queryWrapper Entity wrapper class QueryWrapper
Serializable id primary key ID
Collection<? extends Serializable> idList Primary key ID list

Tips

  • CRUD interface usage is basically the same as MP
  • The Mapper that users need to inherit is BaseEsMapper instead of BaseMapper
  • EE does not provide a Service layer, but directly sinks some of the Service layer methods in MP to the Mapper layer, which will be more convenient for users to use
Help us improve this document (opens new window)
Last update: 2024/03/29
Auto process index
Condition constructor

← Auto process index Condition constructor→

Theme by Vdoing | Copyright © 2021-2025 LaoHan | Zhejiang ICP No. 2022020479 | MIT License
  • 跟随系统
  • 浅色模式
  • 深色模式
  • 阅读模式