How do you update only the modified fields in the Hibernate fields without updating them?? (3 medium method)

Source: Internet
Author: User

1. Modify annotations: Specify that a property is: @Column (updatable=false), which means that a column is not in the updated range. You can also specify update in the property properties of the XML. Less use, no flexibility

2.xml: Set the attribute Dynamic-update for class in the XML configuration file, such as:

<class name= "Student" dynamic-update= "true" >. During the session, it is not possible to rely on dynamic-update, so use the merge. Session2.merge (s); there is no corresponding setting in the JPA standard annotation, and hibernate extends the corresponding functionality.

3.hql| EJBQL statement: Query q=session.createquery ("Update Student s set s.name= ' John ' where S.id=1");(recommended)

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.