Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIKI中中说多对多关系,插入使dao.insertLinks()有所误导。 #59

Closed
liuyxit opened this issue Sep 19, 2011 · 1 comment
Closed
Milestone

Comments

@liuyxit
Copy link

liuyxit commented Sep 19, 2011

原wiki这样写道:

dao.insertLinks(food,"pets");

如果 food.id 的值为 6,那么上述操作实际上会执行:
循环 food.pets 执行执行 SQL 获取 最大值: SELECT MAX(id) FROM t_pet // 假设返回的值是 97
执行 SQL 插入关联: INSERT INTO t_pet_food (foodid, petid) VALUES(6, 97);
...看,并不会插入 food 对象。


事实上,在多对多关系中,应该使用:
dao.insertRelation(food,"pets");
这样不需要产生:
INSERT INTO t_pet (name) VALUES("XiaoBai");
只需要插入中间表记录:
INSERT INTO t_pet_food (foodid, petid) ;

zozoh added a commit that referenced this issue Oct 19, 2011
@zozoh
Copy link
Member

zozoh commented Oct 19, 2011

楼上的错了,那个是给 #50 的提交

zozoh added a commit that referenced this issue Oct 20, 2011
@zozoh zozoh closed this as completed Oct 20, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants