codecamp

HasorDB 写入策略

有如下表

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
}

Insert 忽略该列

对于某些列新增时想使用数据库的默认值忽略来自应用的设置则可采用 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
}


HasorDB 跨Schema映射
HasorDB JDBC Type
温馨提示
下载编程狮App,免费阅读超1000+编程语言教程
取消
确定
目录

关闭

MIP.setData({ 'pageTheme' : getCookie('pageTheme') || {'day':true, 'night':false}, 'pageFontSize' : getCookie('pageFontSize') || 20 }); MIP.watch('pageTheme', function(newValue){ setCookie('pageTheme', JSON.stringify(newValue)) }); MIP.watch('pageFontSize', function(newValue){ setCookie('pageFontSize', newValue) }); function setCookie(name, value){ var days = 1; var exp = new Date(); exp.setTime(exp.getTime() + days*24*60*60*1000); document.cookie = name + '=' + value + ';expires=' + exp.toUTCString(); } function getCookie(name){ var reg = new RegExp('(^| )' + name + '=([^;]*)(;|$)'); return document.cookie.match(reg) ? JSON.parse(document.cookie.match(reg)[2]) : null; }