Hi Everyone,
I've got a JPA+Hibernate app that I'm trying to figure out what exactly the merge function does in EntityManager. In looking closely at our MySQL logs it would appear the merge generates a query which overwrites the state of the entire object to the database. What I would
expect to happen though is that the merge compares each field/property of the entity and only overwrites the pieces that have truly changed.
For instance if I have a Dog entity with properties color and species and I change the color property and call merge the resulting query should be
Code:
update Dog set color=?1 where id=?2
instead of the
Code:
update Dog set color=?1, species=?2 where id=?3
as i'm seeing.
Am I misunderstanding what the merge function is doing or its purpose? Is there some setting or setup that I am missing to make sure MySQL is getting more appropriate queries?
Thanks in advance,
Jean-Philippe