Modify Hibernate entity class field int to generate Java.lang.NoSuchMethodError for integer

Source: Internet
Author: User

Problem Description:

The Hibernate entity class field int is generated as an integer java.lang.NoSuchMethodError, but obviously there is this method, but it has been said that there is no such method. After careful comparison of the bytecode file, the JDK is found in compiling bytecode, the relevant methods will be processed.

The detailed compilation situation is as follows:

Original code:

Net.setpushstatus (Integer.parseint (pushstatus));

Code that is compiled when the entity Class attribute field type is int:

Net.setpushstatus (Integer.parseint (pushstatus));

Code that is compiled when the Entity Class property field type is integer:

Net.setpushstatus (Integer.valueof (Integer.parseint (Pushstatus)));

In the process of converting int to Integer, the class that invokes the field's set method will silently recompile. Therefore, the newly compiled class file needs to be republished.

Similar problems:

1. Use static constants defined by the static final keyword , and if the constant needs to be changed after duty, then all class files that are used to this constant need to be republished.

Cause: Static constants are processed by the JDK directly when they are compiled. Therefore, it is useless to modify only the value of a constant when you modify it later.

Modify Hibernate entity class field int to generate Java.lang.NoSuchMethodError for integer

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.