resultMap
ResultMap is a configuration construct used by MyBatis to describe how the columns of a SQL query map to properties of Java objects. It defines a mapping between a result set and an object graph, enabling both simple and complex mappings, including nested objects and collections, as well as polymorphic mappings.
A resultMap is identified by an id and specifies a result type with the type attribute. It
Common child elements include:
- id: maps a primary key column to a property.
- result: maps a column to a simple property.
- constructor: maps columns to constructor parameters for constructor-based mapping.
- association: maps a nested object, using its own mappings.
- collection: maps a collection or list of nested objects, using ofType to indicate the element type.
- case and discriminator: support conditional or polymorphic mappings to vary the mapped type based on column
Usage examples involve mapping to single objects, nested objects (such as an object with a nested address),