Hello All,
I have a object graph being used in multiple process flows. The root object is annotated to cascade to multiple entities/collections on a save/update.
We are noticing that our application is issuing a lot more updates than it actually should. So, i had some basic questions to expedite my own debugging (while i read the documentation)
1. How does hibernate decide when to cascade? My understanding is that it does that when it deems the objects 'dirty' and it determines that by checking the current snapshot against the one in the persistent cache. it does not rely on equals/hashcode to make this determination. But what would hibernate do if the entity is detached and a 'select before update' is not configured on the entity? Would it always cascade? i think it would but i am seeking a confirmation.
2. How does hibernate differentiate between a new entity vs a detached entity since both do not exist in the current persistent context? i am talking about a scenario where i give a 'new' entity an identifier (primary key). How would hibernate know that it isn't detached but new?
Any pointers/references will help...
|