Three states of Hibernate (children)

Source: Internet
Author: User

V: three states of Hibernate

Instantaneous: The Bean object and session, regardless of the database. Before the Save method of the session object is saved.

Persistent state (Managed): The Bean object is related to the session, and there is a corresponding record in the database. After the Save method is saved, before the session object is turned off. The session knows the object changes, and when the object changes, the session can save the data in the database even after the session saves the object. (S.save--àstr.commit-----s.close)

Update Upddate (produces two statements insert and UPDATE statements) when the object changes in this process

The object that updates the update is in a persistent state.

When an object does not know whether it is in a transient state or a managed state, it uses the Saveorupdate state, allowing hibernate to determine if it is in a transient state or a managed state (Hibernate will determine if the object's ID has a value to be saved or updated. If there is a value then the update is saved if it is not, and the ID is shaped to determine whether the ID is 0. Determine whether to save or update. The String type determines whether an empty decision is an update or a save

Persistent state: Session object is closed, regardless of database. With the session after the session is closed like (the corresponding object ID has a value).

The Un-save primary key defaults to sesssion when the value of the saved worth ID is equal to the value of the Un-save declaration and is directly saved when there is no Saveorupdate method.

Three states of Hibernate (children)

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.