ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Clinton Begin <clinton.be...@gmail.com>
Subject Re: Issue with Interface Mapper that Extends an Interface itself
Date Thu, 10 Dec 2009 20:42:20 GMT
Interface inheritance is not yet supported.  There's a Jira ticket with a
patch submitted, here:

http://issues.apache.org/jira/browse/IBATIS-655

Clinton

On Thu, Dec 10, 2009 at 11:23 AM, Soks86 <michael.chrostowski@gmail.com>wrote:

>
> Hi,
>
> I've been switching my project over to iBATIS from a pretty complete
> Hibernate project. I've run into an issue with how the iBATIS configuration
> seems to look up mapped methods. I'm currently using Beta 5 since my Maven
> isn't seeing repo2.maven.org/org/... for some reason. I have an interface
> dao as such:
>
> public interface Dao<T> {
>    void delete(T arg);
>    void save(T arg);
>    void update(T arg);
>    T load(T arg);
> }
>
> then I have another interface which extends this
>
> public interface SomeTypeDao extends Dao<SomeType> {
>   SomeType loadBySomething(String arg);
> }
>
> and finally my implementation:
>
> public class IbatisSomeTypeDao implements SomeTypeDao {
>   void delete(SomeType arg) {
>      SqlSession session = sessionFactory.openSession();
>      try {
>         SomeTypeDao dao = session.getMapper(SomeTypeDao.class);
>         dao.delete(arg);
>         session.commit();
>      } finally {
>         session.close();
>      }
>      //... other code omitted but present in actual code
> }
>
> My mapping file is for the namespace of SomeTypeDao and that is the only
> mapped interface or class from the three I posted above.
>
> Now when I call IbatisSomeTypeDao.delete(arg) instead of finding my mapped
> interface (SomeTypeDao.delete()) iBATIS seems to look for delete() in my
> Dao<T> class instead and thus it looks for a mapping for Dao<T> (which
> doesn't exist) and then I get this exception:
>
> java.lang.IllegalArgumentException: Mapped Statements collection does not
> contain value for com.icarus.common.dao.Dao.delete
>        at
>
> org.apache.ibatis.session.Configuration$StrictMap.get(Configuration.java:366)
>        at
>
> org.apache.ibatis.session.Configuration.getMappedStatement(Configuration.java:312)
>        at
>
> org.apache.ibatis.binding.MapperMethod.setupCommandType(MapperMethod.java:131)
>        at
> org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:41)
>        at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:18)
>        at $Proxy1.delete(Unknown Source)
>
>
> Am I missing something here? It would seem to me that this is a limitation
> of iBATIS' configuration class. Shouldn't it first look for a mapping for
> SomeTypeDao and find my mapping? I do know for a fact that if I call
> SomeTypeDao.loadBySomething (method that isn't in Dao<T> generic type) then
> the Configuration seems to find the appropriate mapping and doesn't
> complain. However any method that was inherited by the interface is mapped
> to the parent interface it seems.
>
> Ideas? Help?
>
> Thanks.
> --
> View this message in context:
> http://old.nabble.com/Issue-with-Interface-Mapper-that-Extends-an-Interface-itself-tp26732131p26732131.html
> Sent from the iBATIS - User - Java mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-java-unsubscribe@ibatis.apache.org
> For additional commands, e-mail: user-java-help@ibatis.apache.org
>
>

Mime
View raw message