Atitit. hbnt orm db new update best practices o7, atitit. hbntorm

Source: Internet
Author: User

Atitit. hbnt orm db new update best practices o7, atitit. hbntorm

Atitit. hbnt orm db new update best practices o7

 

1. merge and save. 1

2. The POJO object is in the free, persistent, and hosted state. Use of merge. 1

3. @ DynamicInsert @ DynamicUpdate 2

4. Actually calling the SQL statement generated by merge () 2

5. Refer to 2

 

 

1. merge followed the save.

Update

UpdateorSave is no longer recommended...

The generated blackheads have a merge and a save...

 

Author: old wow's paw Attilax iron, EMAIL: 1466519819@qq.com

Reprinted please indicate Source: http://blog.csdn.net/attilax

 

2. The POJO object is in the free, persistent, and hosted state. Use of merge.

Free, persistent, and useful during testing

1. If the free state ID is null and the database does not exist, call merge () to directly Insert the database.

2. In the persistent state, the pojo object retrieves the row record from the database and calls merge () to automatically compare whether the object and the database object have changed. If yes, the row record is updated.

 

3. managed State: Specify the ID, POJO object constructed by the program, and call merge () to automatically compare the attributes of the database's ID row record and POJO object. If not, update them.

However, the POJO object constructed by a program and the ID is specified. However, the pojo id is native and the database sequence is specified. After merge () is called, the ID specified by the program will be changed to a new sequence ID, the POJO object still becomes the Free State where the ID is not empty and the database does not exist.

 

3. @ DynamicInsert @ DynamicUpdate4. the actual SQL statement generated by merge () is called.

First, select

Select gvmaterial0 _. material_id as material1_0_0 _, gvmaterial0 _. application_type as applicat2_0_0 _, gvmaterial0 _. can_down_org as can3_0_0 _, gvmaterial0 _. create_time as create4_0_0 _, gvmaterial0 _. required tie_time as required tie5_0_0 _, gvmaterial0 _. failure_time as failure6_0_0 _, gvmaterial0 _. file_path as file7_0_0 _, gvmaterial0 _. material_description as material8_0_0 _, gvmaterial0 _. material_type as material9_0_0 _, gvmaterial0 _. play_time as play10_0_0 _, gvmaterial0 _. size as size0_0 _, gvmaterial0 _. update_time as update12_0_0 _, gvmaterial0 _. update_user as update13_0_0 _ from gv_material gvmaterial0 _ where gvmaterial0 _. material_id = 1

 

32 Query update gv_material set play_time = 125 where material_id = 1

 

5. Reference

Several update Methods for some fields updated by Hibernate-column in zb0567-blog channel-CSDN.NET.htm




Related Article

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.