Resolves an issue in which the database default property is invalid

Source: Internet
Author: User

Issue background:

This project belongs to the SSH project, and the persistent Layer relational database framework is hibernate. The foreground passes all parameters and parameter values to the background by serializing the form.

Expected effect:

Set the initial value of the field for some number types in the database table to 0.0, and if the foreground form does not populate those fields, the value of the field for these number classes will be the default value 0.0 when the add operation is performed.

Actual effect;

After you perform the add operation, the value of the field of type number is empty, not 0.0

Solve the problem:

Problem with invalid database default property

How to resolve:

In the mapping file *.hbm.xml <class name= ..... dynamic-insert= "true">

Solution principle:

Dynamic-insert= "True, the dynamically generated SQL statement executes, and if the value of the property is null the null field will no longer appear in the dynamic SQL statement, guaranteeing the efficiency of SQL execution.

Extended:

Dynamic-update= "True" is also a dynamically generated SQL statement, and only the properties that you modify will appear in the SQL statement.

Adaptation Range:

A lot of the database table fields are used to help commit SQL statements to run efficiently.

Resolves an issue in which the database default property is invalid

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.