Hint
This article is generated by AI translation.
Document
Mapper files are stored as XML. The basic structure is:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//dbvisitor.net//DTD Mapper 1.0//EN"
"https://www.dbvisitor.net/schema/dbvisitor-mapper.dtd">
<mapper namespace="...">
...
</mapper>
Attributes
| Property | Description |
|---|---|
| namespace | 必选 Usually the fully qualified mapper interface name; each method maps to a SQL operation in this file. |
| caseInsensitive | 可选 Case-insensitive matching for column/property names. Default true. Handy when drivers return uppercase cols. |
| mapUnderscoreToCamelCase | 可选 Convert camelCase properties to snake_case column names (e.g., createTime → create_time). Default false. |
| autoMapping | 可选 Enable auto-mapping. Default true. |
| useDelimited | 可选 (v5.3.4+) Force quoting/delimiters on table/column names when generating SQL. Default false. |
Elements
Top-level XML elements under the root:
- <entity>: map a database table to a type; each type maps once.
- <resultMap>: describe how to load data from result sets.
- <select>: configure SELECT statements.
- <update> / <delete>: configure UPDATE and DELETE.
- <insert>: configure INSERT.
- <execute>: execute arbitrary SQL.
- <sql>: reusable SQL fragments in the same mapper file.
Validate the document
Use XML DTD or XML Schema to validate mapper XML.
Example: validate with DTD
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//dbvisitor.net//DTD Mapper 1.0//EN"
"https://www.dbvisitor.net/schema/dbvisitor-mapper.dtd">
<mapper namespace="...">
...
</mapper>
Example: validate with XML Schema
<?xml version="1.0" encoding="UTF-8"?>
<mapper xmlns="https://www.dbvisitor.net/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.dbvisitor.net/schema https://www.dbvisitor.net/schema/dbvisitor-mapper.xsd"
namespace="...">
...
</mapper>