Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<ul> <li><p>See the <a href="http://forum.hibernate.org/viewtopic.php?t=951275&amp;highlight=difference+persist+save" rel="noreferrer">Hibernate Forum</a> for a explanation of the subtle differences between persist and save. It looks like the difference is the time the INSERT statement is ultimately executed. Since <strong>save</strong> does return the identifier, the INSERT statement has to be executed instantly regardless of the state of the transaction (which generally is a bad thing). <strong>Persist</strong> won't execute any statements outside of the currently running transaction just to assign the identifier. Save/Persist both work on <em>transient instances</em>, ie instances which have no identifier assigned yet and as such are not saved in the DB.</p></li> <li><p><strong>Update</strong> and <strong>Merge</strong> both work on <em>detached instances</em>, ie instances which have a corresponding entry in the DB but which are currently not attached to (or managed by) a Session. The difference between them are what happens to the instance which is passed to the function. <strong>update</strong> tries to reattach the instance, that means that there may be no other instance of the persistent entity attached to the Session right now otherwise a exception is thrown. <strong>merge</strong>, however, just copies all values to a persistent instance in the Session (which will be loaded if it is not currently loaded). The input object is not changed. So <strong>merge</strong> is more general than <strong>update</strong>, but may use more resources.</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload