- Use of universal Mapper
- Import dependency
<dependency>
<groupId>com.github.abel533</groupId>
<artifactid>mapper</artifactid>
<version>2.3.4</version>
</Dependency>
- Configure Plugins
<pluginInterceptor="Com.github.abel533.mapperhelper.MapperInterceptor" >
<!-- primary key self-increment write method mysql, detailed description See document -->
<property name= "IDENTITY" value= "MYSQL" />
<!-- Universal mapper interface, multiple universal interfaces separated by commas -->
<propertyname="mappers"value="Com.github.abel533.mapper.Mapper" />
</plugin>
- The new mapper interface inherits the same mapper provided interface
- Inherit the generic mapper<t> You must specify a generic <T>
- Type of generic (entity Class) <T> must meet requirements
1. The table name uses the class name by default, and the hump turns to underline (only uppercase letters are processed), such as UserInfo the default corresponding table name is User_info .
2. Table name can be used @Table (name = "TableName") Specifies that the table name can be specified in this manner for non-conforming to the first default rule.
3. Field Default and @Column As a table field, the table defaults that the Java object's Field the name hump turns to underline form.
4, you can use @Column (name = "FieldName") Specify a field name that does not conform to rule 3rd
5. Use @Transient annotations can omit fields, and fields that add the annotations are not used as table columns.
6, the proposal must have a @Id Note as the primary key field, you can have more than one @Id The Annotated field is used as the Federated primary key.
- Testing the methods provided
- Generic Example Query object
- Add normal condition
Need to create an object Cirteria object out, through this object, to set some unconventional conditions
For example in the like > <
If there is or in the condition, then new to create a criteria object, and then use Example.or (CC2)
If you use sort: example. Setorderbyclause ("id ASC, age desc")
- Query criteria for adding or
- Add Sort function
Use of universal Mapper