1.创建用于接收blob类型的实体类

 1 @Getter
 2 @Setter
 3 public class FileEntity implements Serializable {
 4     private static final long serialVersionUID = -5544560514334406226L;
 5     //附件类型
 6     private String fileType;
 7     //附件
 8     private byte[] blob;
 9 }

2.在mybaits xml 文件中 配置resultMap

1   <resultMap id="fileResultMap" type="com.domains.entity.FileEntity">
2         <result column="BB10" property="fileType"></result>
3         <result column="FJ" property="blob" jdbcType="BLOB" typeHandler="org.apache.ibatis.type.BlobTypeHandler"></result>
4     </resultMap>

3.SQL语句

1  <select id="getBlob" resultMap="fileEntityResultMap">
2         select BB10,FJ from cb10 where cb100=#{uuid}
3     </select>

blob 类型或被

org.apache.ibatis.type.BlobTypeHandler 转换成 byte[] 并赋值给实体类

相关文章:

  • 2022-12-23
  • 2021-12-05
  • 2021-09-29
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2021-06-21
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案