我的问候!
我很新iBatis
,我遇到过这样的优化问题:我有两个完全相同@Results
的参数,只有一个参数不同。有什么办法可以创建某种注释数组来重用它进行映射?源代码如下所示:
public static interface StoreMapper {
@Select("SELECT * FROM STORE WHERE STORE_NUMBER = #{storeNumber}")
@Results(value = {
@Result(property="storeNumber", column="STORE_NUMBER"),
@Result(property="districtId", column="DISTRICT_ID"),
@Result(property="managerName", column="MANAGER_NAME")})
Store findByStoreNumber (Integer storeNumber) throws FacadeException;
@Select("SELECT * FROM STORE WHERE STATE = #{state}")
@Results(value = {
@Result(property="storeNumber", column="STORE_NUMBER"),
@Result(property="districtId", column="DISTRICT_ID"),
@Result(property="managerName", column="MANAGER_NAME")})
List<Store> findByState (String state) throws FacadeException;
}
我读到,我可以使用 XML,但是有没有办法使用注释来做到这一点?它们非常方便。