I have integrated spring3 + mybatis3,and it worked good.

Then I found that many SQLs will be written like this:

```
select * from table1 where id=#{id}
select * from table2 where id=#{id}

```

We don't need repeat as a programmer!

So,Can we defined a genric dao or mapper to avoid this repeat? Provide a demo is better. 

Some links can help is kindly too.

It bothers me for a long time,need a hand.

I want to write my code like this:

**Test.java**:

```
just a enity.

```

**TestMapper.java**:

```
public interface TestMapper extends GenericMapper {
    public void testMethod1(String..);
    //other methods here
}

```

**GenericMapper.java**:

```
public interface GenericMapper<T, PK> {
    public T select(PK id);
    public boolean update(T t);
    public boolean delete(PK id);
    public boolean insert(T t);
}

```

**defind bean in spring-xx.xml**:

```
<bean id="testMapper" class="org.mybatis.spring.mapper.MapperFactoryBean">
    <property name="sqlSessionFactory" ref="sqlSessionFactory" />
    <property name="mapperInterface" value="com.jackson.mapper.TestMapper" />
</bean>

```

Call in my service layer like this:
// Please\*\*NOTICE\*\*:method **select** is defined in GenericMapper.

**TestService.java**:

```
public TestMapper testMapper;

public Test get(Integer id) {
    Test test = testMapper.select(id);   
    doSmth(test);
}

```

Just a few minutes ago,Someone said we can use a Interceptor interface. And I am trying now. 

Thanks!

--jackson