Go Null value is assigned to a property of primitive type setter of "cause and resolution

Source: Internet
Author: User

Original address: http://blog.csdn.net/kevinzhangfei/article/details/6995316

The "null value is assigned to a property of primitive type setter of" error was reported during the action request data, and was discovered after the search because the corresponding field in the database was Null.

For example:

Java code

<!--The fields in the Hibernate mapping file--

<property name="printtime" type="Long" ><column name="Print_time"/></property>

[Java]View plain?
    1. <!--The fields in the Hibernate mapping file--
    2. <property name="printtime" type="Long" ><column name="Print_time"/></property>

Where the type is hibernate type, in the generated class, the Printtime field is a long type, is a base type, and cannot be null.
Workaround:
First: The database field is not set to null;
The second kind: Manually modify the mapping file, printtime use Java type Long, that is, type= "Java.lang.Long", The Book class field is also changed to Long. Similarly, int is an integer.
Third: Use Java type instead of hibernate type when reverse engineering.

Go Null value is assigned to a property of primitive type setter of "cause and resolution

Related Article

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.