1. 程式人生 > >mybatis中查詢一列使用List封裝資料

mybatis中查詢一列使用List封裝資料

返回結果只有一列,並且是多條資料的情況:
DAO如下:

public List<Date> findById(String id);

mybatis配置檔案如下:

<select id="findById" parameterType="java.lang.String"  resultType="java.util.Date" >
    select t.fdate_value
    from t_pa_table t
    where t.fid = #{id,jdbcType=DECIMAL}
    and t.fselected = 1
  </select
>

說明:resultType=”java.util.Date”中指定Date型別就會自動將資料進行封裝了。
小編在這裡犯得錯誤是:resultType=”java.util.List”,結果就報錯了。