Hibernate allows us to control the contents of the INSERT and UPDATE statements in the mapping file. For example, the Update property setting in the <property element in the mapping file becomes false, and the field will not be included in the basic UPDATE statement. When you modify it, the field will not be included. Insert the same. Dynamic SQL statement Configuration is also very common. The following describes the specific properties of the configuration SQL statement:
1) <property> element Insert property: Set to False, does not include this field in INSERT statement, indicates never to be inserted, default True
2) <property> element Update property: Set to False, does not include this field in the UPDATE statement, means never be modified, default True
3 <class> Element mutable property: Set to False is to set all <property> element's Update property to False, indicating that this object will not be updated, default True
4 <property> Element Dynamic-insert property: Set to True, when the Insert object is generated, generates a dynamic INSERT statement, and if the value of this field is NULL, it is not added to the INSERT statement. Default False
5) <property> element Dynamic-update property, set to True to indicate the update object, generate a dynamic update statement, if the value of this field is null will not be added to the UPDATE statement, the default false
6 <class> Element Dynamic-insert property: Set to True to indicate that all <property> elements have the Dynamic-insert property set to True and the default false
7 <class> Element Dynamic-update property: Set to True to indicate that all <property> elements have the Dynamic-update property set to True and the default false
Hibernate generating dynamic SQL statement consumption of system resources (such as CPU, memory, etc.) is very small, so it will not affect the performance of the system, if the table contains n multiple fields, it is recommended to set the Dynamic-update property and insert property to True, This way, when inserting and modifying data, only the fields that you want to insert or modify are included in the statement. You can save the execution time of the SQL statement and improve the running efficiency of the program.
More depressed when the Hibernate annotation model has not been tested, very depressed AH. I see other people on the internet, but no, who can pass the tutorial, give me a message ah;
Configured in the Hbm.xml attribute
<property name= "UserName" dynamic-update= "false " dynamic-insert= "false"/>
Dynamic-update is true to indicate that when an object is updated, dynamic SQL is generated and is included in the UPDATE statement when the value of the property is changed.
How do you configure it in the hibernate annotation?
Additional
@org. Hibernate.annotations.Entity (Dynamicupdate=true,dynamicinsert=true)