2

I am using mybatis with spring-boot.

class A{
    String name;
    NestedClass nestedClass;

    @NoArgsConstructor(access = AccessLevel.PUBLIC)
    public class Nested {
        String nestedName;
    }

}

@Results({
    @Result(property="name", column = "name_col")
    @Result(property="x.nestedName", column = "nestedName_col")
})

it throws excecption:

Error instantiating class models.A$Nested with invalid types () or values (). Cause: java.lang.NoSuchMethodException: models.A$NestedClass.()

How to force mybatis to construct object nestedClass with default constructor ?

  • Make the class `static` currently it is a non static inner class which requires an instance of A to be even constructed. For more information on static/non-static inner classes see http://stackoverflow.com/questions/70324/java-inner-class-and-static-nested-class . – M. Deinum Nov 29 '16 at 11:06

0 Answers0