ATITIT.HBNT ORM DB new update best Practices o99
1. Merge with a save . 1
2. The POJO object is in a free State, a persistent state, and a managed state. Use the merge() condition. 1
3. @DynamicInsert @DynamicUpdate 2
4. Actual call to merge() generated SQL 2
5. Reference 2
1. Mergewith aSavethe.
Update
Updateorsave has not recommended ...
The resulting black boss has a merge and a save ...
2. POJOThe object is in a free State, a persistent state, and a managed state. UseMerge() of the case.
Free State, persistent state, useful during testing
1, the Free State ID is empty, the database must not exist, call merge (), directly into the database.
2. Persistent state, Pojo the row record that the object fetched from the database, calls merge (), automatically compares the object and the database object for changes, or updates the row record.
3, the host State, by programmatically specifying the ID, the program constructs the Pojo object, calls the merge (), automatically compares the database that ID row record with the Pojo object property. The update is not the same.
However, the Pojo object is constructed by the program and the ID is specified. However, the ID of Pojo is native, and the sequence of the database is specified, after the call to merge (), the program specifies the ID, or it will be changed to a new sequence ID, the Pojo object is also the ID is not empty, the database does not exist in the Free State of the ID.
Author :: old Wow's paw attilax Ayron, email:[email protected]
Reprint please indicate source: Http://blog.csdn.net/attilax
3. @DynamicInsert @DynamicUpdate4. Actual call to merge()The generated SQL
First select in up
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_.effectie_time as effectie5_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 g vmaterial0_ where gvmaterial0_.material_id=1
Query Update gv_material set play_time=125 where material_id=1
5. Reference
Hibernate Updates Several update methods for some fields -zb0567 's Column - Blog channel - CSDN.NET.htm
ATITIT.HBNT ORM DB New update best practices o99