开发者

Hibernate persistence slow on One-To-Many

开发者 https://www.devze.com 2023-01-16 19:44 出处:网络
I have a quite large object tree structure that I persist with Hibernate. This should have been persisted with the root-node first and then the children and so on. However this was not the way th开发者

I have a quite large object tree structure that I persist with Hibernate. This should have been persisted with the root-node first and then the children and so on. However this was not the way th开发者_开发知识库at Hibernate did it, it persisted the child first and than updated the reference column in the child when the parent had been persisted. This is not an optimal way of doing it so I forced the One-To-Many (JoinColum) to be not null (nullable=false).

Now it turns out that everything is even slower, much much slower. I don't understand?!


If it is a bi-directional association you need to map one end as inverse (inverse attribute in xml and mappedBy if you are using annotations).

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号