No default constructor for entity java no parameter constructor

Source: Internet
Author: User

Exception Org.hibernate.InstantiationException:No default constructor for entity

The entity class that is returned when the query is an object instance is the one that hibernate dynamically generates through reflection.

The reflected Class.forName ("ClassName"). newinstance (); requires a corresponding class to provide a parameterless constructor,

This problem occurs when the entity class has a parameter structure, and there is no parameterless structure .


The following is a reference structure and a non-parametric structure .

1, each class in the default case, there will be a parameterless constructor!

2, when the parameter constructor is declared, then the parameterless constructor does not exist and requires a parameterless constructor, it must be re-declared!

3, the constructor is not capable of inheriting

4, in the class constructor, whether it is an argument or a parameterless constructor, by default, the parameterless constructor of the parent class is called first (all the way to the topmost parent), because the method to invoke the parent class inherits must first initialize the parent class.

5, you need to call the parent class constructor in the subclass constructor to display the declaration.




No default constructor for entity java no parameter constructor

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.