休眠动态更新 [英] Hibernate dynamic-update
问题描述
我的问题是,为什么以后的默认行为,不应该是UPDATE只是修改的字段的默认行为? p>
此外,为什么甚至支持未修改字段的更新?是否有理由更新未修改的字段?
我的问题是,为什么晚默认行为,不应该是
是UPDATE的默认行为只是修改的字段?
只更新修改的字段如果有大量的属性被大部分的业务逻辑应用程序修改都是昂贵的。因为它包括脏检查(这是另一个选择查询来标识修改的字段)。当有20个字段并且仅修改少量字段时,这种动态更新是很好的(因为可以在DML语句中添加少量列来执行,以获得性能)。如果超过50%的字段被修改,那么更新所有属性是很好的。所以,选择给开发者决定更新只有修改的字段。
希望我的输入将帮助您理解这一点。如果我错了,专家请纠正我。
I know from here that hibernate is configurable to UPDATE to database only the fields of an entity that have been modified, instead of all the fields of the entity (even if they are not changed). This is the default behaviours.
My question is, why is the later the default behaviour, shouldn't it be the default behaviour to UPDATE just the modified fields?
And further, why is it even supported the UPDATE of unmodified fields? is there a reason to UPDATE unmodified fields?
My question is, why is the later the default behaviour, shouldn't it be the default behaviour to UPDATE just the modified fields?
As updating only modified fields is a costly if there are huge number of properties are get modified by application in most of it's business logic. As it includes dirty checking(which is another select query to identify the modified fields). This dynamic-update is good when there were 20 fields and only few fields are modified(as few columns can be added in DML statement for execution which gains performance). If more than 50% fields are modified then it's good to update all the properties. So, choice is given to developer to decide as to update only modified fields.
Hope my input will help you understanding this. Experts please correct me if I am wrong.
这篇关于休眠动态更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!