NutzCN Logo
问答 使用@One,不会创建外键
发布于 2445天前 作者 Zhouwt998 1387 次浏览 复制 上一个帖子 下一个帖子
标签:

@One(field = "id")
private Educard educard;

18-03-07 15:49:00.712 DEBUG [main] 
CREATE TABLE educard(
id SERIAL,
name VARCHAR(128),
CONSTRAINT educard_pkey PRIMARY KEY (id)
)
18-03-07 15:49:00.751 DEBUG [main] 
CREATE TABLE students(
id SERIAL,
name VARCHAR(128),
age NUMERIC(8),
address VARCHAR(128),
CONSTRAINT students_pkey PRIMARY KEY (id)
)
4 回复

不会建外键的

那我插入数据时候
他没有先插入映射表再插入主表

Students stu = new Students();
        stu.setName("xmmmm");
        stu.setAge(20);
        stu.setAddress("XXX");

        Educard educard = new Educard();
        educard.setName("公交卡");
        stu.setEducard(educard);

        dao.insertWith(stu,"educard");
18-03-07 15:52:54.910 DEBUG [XNIO-2 task-1] INSERT INTO students(name,age,address) VALUES(?,?,?) 
    |     1 |  2 |  3 |
    |-------|----|----|
    | xmmmm | 20 | 贵阳 |
  For example:> "INSERT INTO students(name,age,address) VALUES('xmmmm',20,'贵阳') "
18-03-07 15:52:54.918 DEBUG [XNIO-2 task-1] RUN 
18-03-07 15:52:54.919 DEBUG [XNIO-2 task-1] INSERT INTO educard(name) VALUES(?) 
    |   1 |
    |-----|
    | 公交卡 |
  For example:> "INSERT INTO educard(name) VALUES('公交卡') "
18-03-07 15:52:54.920 DEBUG [XNIO-2 task-1] RUN 

啥意思?? 两个id都是序列, 怎么能关联??

添加回复
请先登陆
回到顶部