Mapper interfaces extending other interfaces

188 views
Skip to first unread message

Josh Kamau

unread,
Jul 9, 2011, 4:15:39 AM7/9/11
to mybati...@googlegroups.com
Hi team,

I have some mapper interfaces that have same methods. I want to put all the common methods in a generic interfaces so that all mapper interfaces will extend that interface. Does mybatis work that way ?

i have:
public interface BaseMapper<T> {
  public List<T> getList();
}

and
public interface UserMapper<User> {
   public List<User> getList();
}

Am using mybatis with mybatis-guice. Am asking this because refactoring this will break so much of the existing code. so i need to know in advance if this works

Kind regards.

Josh.

Josh Kamau

unread,
Jul 9, 2011, 8:23:58 AM7/9/11
to mybati...@googlegroups.com
It works!

Simone Tripodi

unread,
Jul 11, 2011, 6:30:59 PM7/11/11
to mybati...@googlegroups.com
Hi Josh!!!
thanks for sharing a feature I wasn't aware :D

Anyway IIUC you meant

{code}
public interface BaseMapper<T> {

List<T> getList();

}
{code}

and

{code}
public interface UserMapper
extends BaseMapper<User> {
}
{code}

right?
TIA, have a nice day!!!
Simo

http://people.apache.org/~simonetripodi/
http://www.99soft.org/

Josh Kamau

unread,
Jul 12, 2011, 12:55:10 AM7/12/11
to mybati...@googlegroups.com
Yea, thats it Simo. And you dont have to repeat all those mapper interface methods.

regards.
Josh.
Reply all
Reply to author
Forward
0 new messages