Hibernate data update-session. Update/session. saveorupdate

Source: Internet
Author: User

Keyword: hibernate update saveorupdate

Hibernate data update-session. Update/session. saveorupdate
Session. Update:

1. First, search for the key of the object to be updated in the internal cache of the current session. If it is found, the current object is considered to be in the persistent state and return. From this point, we can see that calling the update statement for an object in the persistent State does not play any role.
2. initialize the status information of the object (as the basis for dirty data check) and include it in the internal cache. Pay attention to the session here. the update method does not send an update SQL statement to update the data. execute (transaction. commit will call the session before the database transaction is actually committed. flush ).
Session. saveorupdate execution steps:

1. First, search in the internal cache of the session. If it is found, it will be returned directly.
2. Execute the Interceptor. isunsaved method corresponding to the object class (if any) to determine whether the object is not saved.
3. Determine whether the object is in the unsaved state based on unsaved-value.
4. If the object is not saved (transient state), call the Save method to save the object.
5. If the object is not saved (in the detached state), call the update method to re-associate the object with the session.

As you can see, the combined application of the SAVE and update Methods in saveorupdate is actually used. It does not add new features.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.