Groups
Groups
Sign in
Groups
Groups
bamboo-cn
Conversations
About
Send feedback
Help
关于实例的id生成时期的讨论
0 views
Skip to first unread message
Tang Daogang
unread,
Apr 13, 2012, 7:00:23 AM
4/13/12
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to bamb...@googlegroups.com
意识到在生成实例对象的时候,就生成id,确实可能会发生问题。
比如,handler1里面,有 一段代码生成了模型A的一个实例的a, id,但还没有保存。
这个时候,如果另一个进程handler1中,这段代码又生成了一个模型A的实例b,它的id会和a的id一样,如果b抢在a之前保存,则a无法保存。
也即不能保存操作原子性。
所以,必须在保存到数据库之后才有id。生成实例的时候,不能有id。
--
Nothing is impossible.
Reply all
Reply to author
Forward
0 new messages