Skip to main content

Camel Case

Hint

This article is generated by AI translation.

Java classes are typically camel-cased, while databases often use snake case. Enable mapUnderscoreToCamelCase to convert automatically.

Example 1: convert camel case to snake case
@Table(mapUnderscoreToCamelCase = true)
public class AdminUsers { // Maps to table admin_users
private Integer id; // Maps to column id
private String name; // Maps to column name
private Integer age; // Maps to column age
private Date createTime; // Maps to column create_time

// getters and setters omitted
}
Example 2: enable conversion in XML auto-mapping
<!-- entity tag shown; resultMap works the same -->
<entity type="com.example.dto.AdminUsers" mapUnderscoreToCamelCase="true"/>
Scope

Camel-case conversion is off by default; enable it where needed:

  • Specific table: set mapUnderscoreToCamelCase on @Table or on <resultMap>/<entity>.
  • Mapper file: set it on the mapper root element so all <resultMap>/<entity> inherit it.
  • Global: enable via Options at startup or set a default in configuration.