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

exception when namespace attribute of a mapper corresponds to a real class name

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 3.0 Beta 6
    • 3.0 Beta 7
    • Core
    • None
    • WinXP/Java 1.6

    Description

      If you have a following class:


      package com.xxx.ibatis.test.dao;

      public class T1DAO {
      ...
      }

      And a mapper:
      <mapper namespace="com.xxx.ibatis.test.dao.T1DAO">
      ...
      <!-- Select with no parameters using the result map for Account class. -->
      <select id="selectAllT1" resultMap="T1Result">
      select * from t1
      </select>
      </mapper>

      Then when trying to instantiate an SqlSessionFactory execution fails with the following exception:

      Caused by: org.apache.ibatis.binding.BindingException: Only interfaces can be configured by the MapperFactory. Type class com.xxx.ibatis.test.dao.T1DAO is not an interface.
      at org.apache.ibatis.binding.MapperRegistry.addMapper(MapperRegistry.java:35)
      at org.apache.ibatis.session.Configuration.addMapper(Configuration.java:320)
      at org.apache.ibatis.builder.xml.XMLMapperBuilder.bindMapperForNamespace(XMLMapperBuilder.java:234)
      at org.apache.ibatis.builder.xml.XMLMapperBuilder.parse(XMLMapperBuilder.java:40)
      at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:226)
      at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:66)

      The namespace should not force you to use mapper interfaces in my opinion.
      If namespace points to a concrete class the mapper should ignore it not trying to use mapper interfaces logic and treat it, well, as a regular namespace string qualifier.
      What is I already have a bunch of DAO classes and just want to scope them appropriately inside correspondent maps?

      Attachments

        Activity

          People

            cbegin Clinton Begin
            osyabender Ostap Bender
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: