Introduction of Wrapper
提示
If you have previously understood the MP conditional constructors, then you only need to pay attention to MP in the absence of the indexed conditional constructors, the rest is almost the same as MP. The conditional constructor is the core of the entire framework, the CRUD query conditions are basically encapsulated by it, but also relies on it to provide the chain API and MP syntax to simplify the use of the entire ES complex API, it can be understood as a converter or intermediary, as if you want to eat dumplings, you can go to your sister-in-law said you want to eat You can go to your sister-in-law and tell her that you want to eat dumplings stuffed with leeks, and she will do the rest... Wrapper can be created in two ways:
- Directly new, e.g. new
LambdaEsQueryWrapper<>()
. - Created by EsWrappers.lambdaQuery(), which can support chained programming scenarios, against MP's Wrappers
Description
- The first input boolean condition that appears below indicates whether the condition is added to the last generated statement, for example: query.like(StringUtils.isNotBlank(name), Entity::getName, name) .eq(age!=null && age >= 0 , Entity::getAge, age)
- The following block of code has multiple methods to complete the individual boolean input from top to bottom, the default is true
- The following appearances of the generic Param are all subclass instances of Wrapper (all have all the methods of AbstractWrapper)
- The following methods appear in the input parameters of R is a generic, in the ordinary wrapper is a String, in the LambdaWrapper is a function (example: Entity::getId, Entity is the entity class, getId is the field id getMethod)
- R column in the following method parameters are database fields, when the specific type of R is String, it is the name of the database field (field name is the database keyword wrapped in its own escape character!) ! Instead of entity class data field name!!! Another project runtime does not support eclipse's own compiler when the specific type of R is SFunction!
- The following examples are the use of ordinary wrapper, the reference to Map and List are in the form of json performance!
- Use if the Map or List reference is empty, it will not be added to the last generated sql!
- Any questions on the open source code to see, can not see the function click me to learn new knowledge (opens new window)
Warning
Wrapper transfer in RPC calls is not supported and discouraged
- wrapper is heavy
- transferring wrapper is analogous to your controller receiving values in a map (development for a while, maintenance for a crematorium)
- the correct posture for RPC calls is to write a DTO for transmission, and the called party then performs the appropriate action according to the DTO We refuse to accept any issue or even pr related to RPC transfer Wrapper error.
# AbstractWrapper
Description
The parent classes of QueryWrapper(LambdaEsQueryWrapper) and UpdateWrapper(LambdaEsUpdateWrapper) are used to generate where conditions for statements, and the entity property is also used to generate where conditions for statements Note: The entity-generated where conditions generated by the entity are not associated with the where conditions generated using the respective api.
# QueryWrapper
Description
Inherits from AbstractWrapper , its own internal property entity is also used to generate where conditions and LambdaEsQueryWrapper
# UpdateWrapper
Description
Inherits from AbstractWrapper , its own internal property entity is also used to generate the where condition and LambdaEsUpdateWrapper
# AbstractChainWrapper
Description
Inherits from Wrapper , used to support chain calls