Myk*_*ych 1 java annotations mybatis
下面的代码是正常工作的mapper类,但是它具有结果集声明的复制内容(在我的情况下这是很大的)。
如何重用@Results声明?
@Mapper
public interface DailyMasterCurrentTradeDao {
@Select("select * from dly_mstr_curr_trd")
@Results({
@Result(property = "accAdsStC", column = "ACC_ADS_ST_C"),
...
})
List<DailyMasterCurrentTrade> selectDailyMasterCurrentTrades();
@Select("select * from dly_mstr_curr_trd where rownum < #{rownumThreshold}")
@Results({
@Result(property = "accAdsStC", column = "ACC_ADS_ST_C"),
...
})
List<DailyMasterCurrentTrade> selectFewDailyMasterCurrentTrades(long rownumThreshold);
}
Run Code Online (Sandbox Code Playgroud)
您可以使用@ResultMap引用/重用另一个@Results定义。
@Select("SELECT * FROM user where id = ${value}")
@ResultMap("userResult")
User findOne(Long id);
@Select("SELECT * FROM user")
@Results(id = "userResult", value = {
@Result(property = "id", column = "id", id = true),
@Result(property = "name", column = "name"),
@Result(property = "phone", column = "phone")
})
List<User> findAll();
Run Code Online (Sandbox Code Playgroud)
有关详细信息,请参见此处:https : //github.com/mybatis/mybatis-3/issues/155
| 归档时间: |
|
| 查看次数: |
2163 次 |
| 最近记录: |