有如下表
create table `test_user` (
`id` int(11),
`name` varchar(255),
`age` int,
`create_time` datetime,
primary key (`id`)
);
在明確映射關(guān)系中可以精確的指定表名和列名。將 ?autoMapping
?設(shè)置為關(guān)閉然后為每表和每一個列配置映射的名字。
// name = "test_user" 表名
// autoMapping = false 關(guān)閉屬性字段自動映射(默認(rèn)true),全部通過 @Column 配置
@Table(name = "test_user", autoMapping = false)
public class TestUser {
@Column(name = "id", primary = true)
private Integer id;
@Column("name")
private String name;
@Column("age")
private Integer age;
@Column("create_time")
private Date createTime;
// getters and setters omitted
}
更多建議: