mybatis java.lang.ClassCastException

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

mybatis java.lang.ClassCastException

tao lee wang
org.apache.ibatis.session.Configuration$StrictMap$Ambiguity cannot be cast to org.apache.ibatis.mapping.MappedStatement


```
Configuration configuration = sqlSession.getConfiguration();
MapperRegistry mapperRegistry = configuration.getMapperRegistry();
Collection<Class<?>> mappers = mapperRegistry.getMappers();

Collection<MappedStatement> mappedStatements = configuration.getMappedStatements();
for (MappedStatement mappedStatement : mappedStatements) {
System.out.println(mappedStatement.getId());
System.out.println(mappedStatement.getParameterMap());
List<ResultMap> resultMaps = mappedStatement.getResultMaps();
System.out.println(resultMaps);
}
```

the `for (MappedStatement mappedStatement : mappedStatements)`  exception 

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/6bcc3b5b-02cc-41ff-b601-66e072a71286n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis java.lang.ClassCastException

Guy Rouillier-2
What version of MyBatis are you using?  I have some old code that is doing the following:

   Collection mappedStatements = getSqlSessionManager().getConfiguration().getMappedStatements();
    for (Object obj : mappedStatements) {
      if (!(obj instanceof MappedStatement)) {
        continue;
      }
      MappedStatement mp = (MappedStatement) obj;
   }

Unfortunately, I don't have time at the moment to do some debugging on this, but if you just want to get your code working, try this.

On Wed, 2020-09-16 at 18:08 -0700, tao lee wang wrote:
org.apache.ibatis.session.Configuration$StrictMap$Ambiguity cannot be cast to org.apache.ibatis.mapping.MappedStatement


```
Configuration configuration = sqlSession.getConfiguration();
MapperRegistry mapperRegistry = configuration.getMapperRegistry();
Collection<Class<?>> mappers = mapperRegistry.getMappers();

Collection<MappedStatement> mappedStatements = configuration.getMappedStatements();
for (MappedStatement mappedStatement : mappedStatements) {
System.out.println(mappedStatement.getId());
System.out.println(mappedStatement.getParameterMap());
List<ResultMap> resultMaps = mappedStatement.getResultMaps();
System.out.println(resultMaps);
}
```

the `for (MappedStatement mappedStatement : mappedStatements)`  exception 
--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/6bcc3b5b-02cc-41ff-b601-66e072a71286n%40googlegroups.com.
-- 
--
Guy Rouillier

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/866e172e970a2e9feff0f937f1bc88f9e363d4f1.camel%40gmail.com.