Uploaded image for project: 'iBatis for Java [READ ONLY]'
  1. iBatis for Java [READ ONLY]
  2. IBATIS-655

Inheritance of Mapper interfaces works wrong

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0 Beta 3
    • 3.0 Beta 9
    • Core
    • None
    • nothing special in environment

    Description

      I'm trying to declare mappers in some common way.

      1. I have declared one common mapper interface to inherit it methods for other mappers:
      interface AbstractMapper<T> {
      T find(long id);
      void update(T t);
      void insert(T t);
      }

      2. Then I have declared child interface:
      interfcae UserMapper extends AbstractMapper<User> {
      void traceLoginEventIntoLogTable(User u);
      //rest of methods should me inherited from AbstractMapper interface. I think so.
      }

      3. But when I run this code I had exception for statement:
      SqlSession.getMapper(UserMapper.class).find(1L);
      Exception was something like this:
      Exception in thread "main" java.lang.IllegalArgumentException: Mapped Statements collection does not contain value for demo.AbstractMapper.find
      at org.apache.ibatis.mapping.Configuration$StrictMap.get(Configuration.java:365)
      at org.apache.ibatis.mapping.Configuration.getMappedStatement(Configuration.java:311)
      at org.apache.ibatis.binding.MapperMethod.determineCommandType(MapperMethod.java:79)
      at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:33)
      at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:16)
      at $Proxy1.find(Unknown Source)
      at ibatisdemo.Main.main(Main.java:46)

      4. I think it's because method find is declared in "demo.AbstractMapper",
      but I have expected to use "demo.UserMapping.find" mapping.


      If full demo is needed I can find and attach it in mean time.

      Attachments

        1. inheritance_patch.txt
          3 kB
          Paul Trepagnier

        Activity

          People

            cbegin Clinton Begin
            mamonov Dmitry Mamonov
            Votes:
            5 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: