Cause of Java. Lang. instantiationexception in ibatis

Source: Internet
Author: User

The following error occurs when you use ibatis to query data:

Java. Lang. instantiationexception: COM. Mangocity. Contract. EJB. roomtype, which literally means the. roomtype class cannot be instantiated. The roomtype class is used to encapsulate the query results. Each instance represents a query record. The following is a snippet of my ibatis configuration file:

<Select id = "queryroomtype" parameterclass = "Java. Lang. Long" resultclass = "com. Mangocity. Contract. EJB. roomtype">

Select

A. Upload _id as upload ID,

A. room_type_id as roomtypeid,

A. room_name as roomname

From htl_ii.v_roomtype

Where a. Route _id = # value #

</SELECT>

After searching for information, we found that the cause of this error is that there is no construction method without parameters in the roomtype class, because ibatis is being created in the object, an object is created using a constructor without parameters. Currently, my roomtype class has only one constructor with parameters.

Solution: Add a constructor without parameters to the roomtype class. The method does not have to perform any operations, just like the default constructor.

InHibernateEach persistence class must contain a constructor without parameters.

 

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.