Mapper is a MyBatis-specific library that provides annotation-driven object-relational mapping, enabling single-table CRUD operations without writing SQL or XML. It uses Java reflection and field-level annotations to map entity fields to database columns, configure primary key generation strategies, and generate mapper interfaces and model classes from database schemas.
The library distinguishes itself through several practical capabilities. It includes a safe operation guard that blocks delete and update calls lacking query conditions, preventing accidental full-table modifications. Its example object query builder constructs dynamic WHERE clauses by introspecting populated fields on a plain Example object, avoiding string concatenation. The generic base mapper pattern defines a parameterised base interface with common CRUD methods that concrete mappers inherit, eliminating repetitive method declarations. Developers can also register mapper interfaces automatically through annotations, extend base interfaces with custom methods, and replace default entity-to-table mapping logic with custom implementations.
Beyond its core identity, Mapper supports property-based queries that retrieve records based on specific entity property values, and provides code generation tools that produce mapper interfaces and model classes from database schema metadata. The library's configuration surface includes automatic mapper registration and customisable entity-to-table mapping resolution.