W3Cschool
恭喜您成為首批注冊用戶
獲得88經(jīng)驗值獎勵
有如下表
create table `test_user` (
`id` int(11),
`name` varchar(255),
`age` int,
`create_time` datetime,
primary key (`id`)
);
如若 ?test_user
?表的 ?create_time
?列不允許被更新,那么需要配置 ?@??Column
???注解 ?update = false
? 表示該列不參與更新。
@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(name = "create_time", update = false) // 列不參與更新
private Date createTime;
// getters and setters omitted
}
對于某些列新增時想使用數(shù)據(jù)庫的默認(rèn)值忽略來自應(yīng)用的設(shè)置則可采用 insert 屬性
@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(name = "create_time", insert = false) // 列不參與新增
private Date createTime;
// getters and setters omitted
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網(wǎng)安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: