mybatis报错:@one and @Many不能同时存在@Result中

GoogleVip8 1年前 ⋅ 1785 阅读

记一次mybatis报错

MyBatis 3.2.6. Always generates an error

@Result(property="org", column="ORG_ID", javaType=OrgEntity.class,
   one=@One(select="myapp.mapper.OrgMapper.selectOrg")),
org.apache.ibatis.builder.BuilderException: Cannot use both @one and @Many annotations in the same @Result
at org.apache.ibatis.builder.annotation.MapperAnnotationBuilder.hasNestedSelect(MapperAnnotationBuilder.java:522)

in code

private boolean hasNestedSelect(Result result) {
  boolean hasNestedSelect = result.one().select().length() > 0;
  if (hasNestedSelect) {
    throw new BuilderException("Cannot use both @One and @Many annotations in the same @Result");

It would be very useful to extend the functional annotation @one and @Many

cange from

@One(select="myapp.mapper.OrgMapper.selectOrg")

to

@One(select="selectOrg", mapper=OrgMapper.class)

问题解决! QQ20190620-0.png

错误源代码参考


全部评论: 0

    我有话说: