簡體   English   中英

如何使用Mybatis選擇存儲在mysql數據庫中的映像

[英]How to use mybatis to select image that store in mysql database

我有一堂課

public class Images{ 
    private int id;
    private byte[] img;
    private String name;
}

數據庫T_image中的表(id tinyint,logo_img mediumblob,名稱varchar)

我有一個dao界面

public interface ImgDAO{
  public List<byte[]> selectAllImg();
}

我想在mybatis的xml映射器中為此編寫sqlmapper

像這樣使用resultMap

<resultMap class="Images" id="imageResultMap">
       <result column="logo_img" property="img" jdbcType="BLOB"/>
  </resultMap>

  <select id="selectAllImg" resultMap="imageResultMap">
        select logo_img from T_image
  </select>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM