阅读(1686) (1)

HasorDB 跨Schema映射

2021-12-29 13:51:15 更新

有如下两张表

create table `db_1`.`test_user` (
`id` int(11),
`name` varchar(255),
`age` int,
`create_time` datetime,
primary key (`id`)
);

create table `db_2`.`test_user` (
`id` int(11),
`name` varchar(255),
`age` int,
`create_time` datetime,
primary key (`id`)
)

如要同时映射它们则需要通过​ @Table ​注解的 schema 属性来分别标识它们所属的 schema。

@Table(schema = "db_1", name = "test_user")
public class TestUserForMy {
    // fields and getters and setters omitted
}

@Table(schema = "db_2", name = "test_user")
public class TestUserForYou {
    // fields and getters and setters omitted
}