Atitit. hbnt orm db new update best practices o99, ormo99
Atitit. hbnt orm db new update best practices o99
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...
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.
Author: old wow's paw Attilax iron, EMAIL: 1466519819@qq.com
Reprinted please indicate Source: http://blog.csdn.net/attilax
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