mybatis java.lang.ClassCastException

177 views
Skip to first unread message

tao lee wang

unread,
Sep 16, 2020, 9:08:45 PM9/16/20
to mybatis-user
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 

Guy Rouillier

unread,
Sep 17, 2020, 3:08:28 AM9/17/20
to mybati...@googlegroups.com
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.
--
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 mybatis-user...@googlegroups.com.
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
Reply all
Reply to author
Forward
0 new messages