mybatis 处理 mysql 表中的 text类型的 字段
在mysql 中 text类型的字段: service_detail text NULL 服务描述 。 对应java文件中 model 中的 String: private String serviceDetail;
在 mybatis 中的xml 中定义的是 :
<resultMap id="ResultMapWithBLOBs" type="com.eachonline.goods.model.ServiceGoodsBase" extends="BaseResultMap" >
<result column="service_detail" property="serviceDetail" jdbcType="LONGVARCHAR" />
</resultMap>
基本表的定义:
<resultMap id="BaseResultMap" type="com.goods.model.ServiceGoodsBase" >
<id column="sid" property="sid" jdbcType="VARCHAR" />
<result column="service_name" property="serviceName" jdbcType="VARCHAR" />
<result column="service_district" property="serviceDistrict" jdbcType="VARCHAR" />
<result column="longitude" property="longitude" jdbcType="VARCHAR" />
<result column="latitude" property="latitude" jdbcType="VARCHAR" />
<result column="address" property="address" jdbcType="VARCHAR" />
<result column="service_fee" property="serviceFee" jdbcType="DOUBLE" />
<result column="service_price" property="servicePrice" jdbcType="DOUBLE" />
<result column="service_unit" property="serviceUnit" jdbcType="VARCHAR" />
<result column="user_service_type_id" property="userServiceTypeId" jdbcType="VARCHAR" />
<result column="service_type" property="serviceType" jdbcType="VARCHAR" />
<result column="release_time" property="releaseTime" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" /> </resultMap>
<sql id="Base_Column_List" >
sid, service_name, service_district, longitude, latitude, address, service_fee, service_price,
service_unit, user_service_type_id, service_type, release_time, create_time, is_use,
module, check_status, check_comment, click_num, discount, service_status, service_sale_num,
data_source, commodity_type
</sql>
<sql id="Blob_Column_List" >
service_detail
</sql>
<select id="selectByPrimaryKey" resultMap="ResultMapWithBLOBs" parameterType="java.lang.String" >
select
<include refid="Base_Column_List" />
,
<include refid="Blob_Column_List" />
from service_goods_base
where sid = #{sid,jdbcType=VARCHAR}
</select>
对于修改的操作,有两个方法: updateByPrimaryKeySelective , updateByPrimaryKeyWithBLOBs
mybatis 处理 mysql 表中的 text类型的 字段的更多相关文章
- MYSQL表中向SET类型的字段插入值时值之间不能有空格
MYSQL 中有一种数据类型是 SET,首先我们查看一个包含 SET 类型字段的表结构: 接下来我们向表中插入数据: 按照上面的语句插入数据发现报错了,于是去掉了插入值之间的空格,然后插入成功:
- 数据库表中存在Text类型的属性时,写sql语句时需要注意喽!
之前,习惯性地写查询语句时,查询条件用“=”判断.今天写程序的时候,查询时突然报了一个错误:数据类型text 和varchar 在equal to 运算符中不兼容.查看了一下数据库发现,其中有一个属性 ...
- mysql 表中已经存在数据 修改字段类型 varchar(11) 改为 int(11)
update tablename set s_role = '' alter table tablename modify column s_role int(11)
- MYSQL表中设置字段类型为TIMESTAMP时的注意事项
在MYSQL中,TIMESTAMP类型是用来表示日期的,但是和DATETIME不同,不同点就不再这里说明了. 当我们在使用TIMESTAMP类型设置表中的字段时,我们应该要注意一点,首先我们在表中新增 ...
- 着重基础之—MySql Blob类型和Text类型
着重基础之—MySql Blob类型和Text类型 在经历了几个Java项目后,遇到了一些问题,在解决问题中体会到基础需要不断的回顾与巩固. 最近做的项目中,提供给接口调用方数据同步接口,传输的数据格 ...
- mysql语句中把string类型字段转datetime类型
mysql语句中把string类型字段转datetime类型 在mysql里面利用str_to_date()把字符串转换为日期 此处以表h_hotelcontext的Start_time和En ...
- MySQL表中的数据类型
数据类型:在表中数据类型主要是限制字段必须以什么样的数据类型传值. 一 整型 整数类型:TINYINT SMALLINT MEDIUMINT INT BIGINT总共有五种,name我们一般用到的也就 ...
- 清除mysql表中数据
delete from 表名; truncate table 表名; 不带where参数的delete语句可以删除mysql表中所有内容,使用truncate table也可以清空mysql表中所有内 ...
- SQL查询数据库中所有指定类型的字段名称和所在的表名
--查询数据库中所有指定类型的字段名称和所在的表名 --eg: 下面查的是当前数据库中 所有字段类型为 nvarchar(max) 的字段名和表名 SELECT cols.object_id , co ...
随机推荐
- js 父窗口与子窗口交互
showModalDialog 父窗口 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> ...
- 域对象的引用,ActionContext 和ServletActionContext类的使用
ActionContext 获取 域引用的map ServletActionContext获取具体域对象 //域范围 ActionContext ac = ActionContext.getConte ...
- asp.net 查询本地excel 获取信息
string filepath = @"D:\test1.xls"; string sheetname = "Sheet5"; ...
- python DataFrame获取行数、列数、索引及第几行第几列的值
print df.columns.size#列数 2 print df.iloc[:,0].size#行数 3 print df.ix[[0]].index.values[0]#索引值 0 print ...
- python \uxxxx转中文,Python列表中的字典 \uxxxx转中文,
import json a = [{u', u'roleFlag': 7}] print json.dumps(a).decode("unicode_escape") 输出结果是: ...
- JUC组件扩展(二)-JAVA并行框架Fork/Join(三):在任务中抛出异常
在java当中,异常一共分为两种.一种是运行时异常,一种是非运行是异常. 非运行时异常:这些异常必须在方法上通过throws子句抛出.或者在方法体内进行try{…}catch{…}来捕获异常. 运行时 ...
- Spring Boot(四):利用devtools实现热部署,改动代码自动生效
一.前言 spring-boot-devtools是一个为开发者服务的一个模块,其中最重要的功能就是自动应用代码更改到最新的App上面去.原理是在发现代码有更改之后,重新启动应用,但是速度比手动停止后 ...
- 解决:std::ostream operator<< should have been declared inside 'xxx'
用VS的NMAKE构建,不会报错,但是用GNU MAKE构建,就会报错.(尝试删除Toast.h中第24行的声明) 因此在遇到类似的情况的时候,记得不仅class里面要有friend声明,namesp ...
- jquery几个按钮同时调用一个方法
- word中特殊符号的替换
首先在word里替换快捷键是ctrl+H,点击“更多”,会出现更多选项,在特殊格式那里可以选在各种符号,比如回车,空格什么的. 有的时候在word里看不到一些格式,需要点一下下图的对着的两个箭头图标: ...