Explain dynamic insert and dynamic update properties in Hibernate

1 post / 0 new
admin
Explain dynamic insert and dynamic update properties in Hibernate

Answer

Hibernate creates SQL statements for CRUD operations for each of its persistent classes during application startup and cache them in memory. The cached update statement will update every field even if the value isn’t changed; it is simply updated with the old value. Turning off this feature may improve the startup time for the application.

You can turn off this feature using dynamic-insert and dynamic-update attributes of the class element in a mapping file or using @DynamicInsert, with @DynamicUpdate annotations at the class level.

With the dynamic-insert property set to true, Hibernate does not include null values for properties that are not set by the application, during an INSERT. With the dynamic-update property set to true, Hibernate does not include unmodified properties in the UPDATE.

 

Sample Mapping file snippet

<hibernate-mapping package="com.javajee.hibexamples" auto-import="false">

<class name="Sample" table="SAMPLE" dynamic-insert="true" dynamic-update="true">

</hibernate-mapping>

Was it useful?

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!