Mybatis the data encapsulation class in the mapping file uses the inner class

Source: Internet
Author: User

In general applications, the ORM will be used to map the database isolated records as an entity class, the entity class we are generally a class written in a class file, but sometimes we will use the internal class, this time mapping file configuration should be noted:

If the class is:

Com.xxx.entity.DataWrapper.InnerEntity

Innerentity as a public static member of Datawrapper, the declaration is as follows

1.

Import com.xxx.entity;

...

Datawrapper.innerentity myObject = null;

2.

Com.xxx.entity.DataWrapper.InnerEntity myObject = null;

In mybatis like above as ReturnType or Paramtype will appear ClassNotFound exception, which is related to his classloader mechanism, the above class Javac compiled inner class result is Datawrapper$ Innerentity.class file.

Therefore, when configuring the mapping file, change com.xxx.entity.DataWrapper.InnerEntity to Com.xxx.entity.DataWrapper$innerentity, So the mybatis can be loaded normally.

Mybatis the data encapsulation class in the mapping file uses the inner class

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.