我有简单的4个表的结构:
Table a - columns: id(generated), x
Table b - columns: id(generated), a_id(fk to a), y
Table c - columns: id(generated), a_id(fk to a), z
Table d - columns: id(generated), b_id(fk to b), c_id(fk to c), w关系如下:
a->b one-to-many unidirectional;
a->c one-to-many unidirectional;
b->d one-to-many unidirectional;
c->d one-to-many unidirectional;hibernate在持久化时执行不正确的插入顺序:
应为a、b、c、d
执行: a、b、d,并且在没有生成c_id的情况下失败
我如何执行正确的命令?
谢谢
发布于 2013-01-30 23:44:36
您可以在c之后强制执行flush语句,让hibernate将其发送到db。也就是说,创建并填充a、b、c,然后刷新。然后创建d。
https://stackoverflow.com/questions/14607335
复制相似问题