Mr.Eddart
Mr.Eddart

Reputation: 10273

Hibernate dynamic-update

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?

Upvotes: 0

Views: 759

Answers (1)

Pokuri
Pokuri

Reputation: 3082

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.

Upvotes: 3

Related Questions