首页 > 代码库 > mybatis 插入null 时需要指定jdbcType

mybatis 插入null 时需要指定jdbcType

MyBatis 插入空值时,需要指定JdbcType 
mybatis insert空值报空值异常,但是在pl/sql不会提示错误,主要原因是mybatis无法进行转换

	<insert id="insertInstrument" parameterType="com.labway.oa.po.Instruments">
		insert into
		instruments
		(group_name,
		name,
		description,
		on_line,
		operator,
		x_sbxh,
		serial_no,
		x_lc,
		x_sbjd,
		vendor,
		<!-- x_sbsx, -->
		location,
		changed_on,
		changed_by,
		removed,
		low_threshold,
		high_threshold,
		stability_delta,
		stability_number,
		port_number,
		discard_time,
		size_limit,
		time_out,
		polling_time,
		needs_calibration,
		needs_pm,
		holds_samples,
		include_subdirs,
		debug,
		store_in_db_file,
		db_file_prompt,
		x_jlsx,
		x_funcheck_status,
		x_timecheck_status,
		x_name,
		x_description,
		x_funcheck_date,
		x_timecheck_date,
		pm_date,
		x_pm_status,
		x_status,
		x_group_name
	

		) values(
		#{group_name,jdbcType=VARCHAR},
		#{name,jdbcType=VARCHAR},
		#{description,jdbcType=VARCHAR},
		#{on_line,jdbcType=VARCHAR},
		#{operator,jdbcType=VARCHAR},
		#{x_sbxh,jdbcType=VARCHAR},
		#{serial_no,jdbcType=VARCHAR},
		#{x_lc,jdbcType=VARCHAR},
		#{x_sbjd,jdbcType=VARCHAR},
		#{vendor,jdbcType=VARCHAR},
		<!-- #{x_sbsx}, -->
		#{location,jdbcType=VARCHAR},
		#{changed_on,javaType=String,jdbcType=DATE,typeHandler=com.labway.portal.handler.LwDateTypeHandler},
		#{changed_by,jdbcType=VARCHAR},
		‘F‘,
		‘0‘,
		‘0‘,
		‘0‘,
		‘0‘,
		‘0‘,
		‘0‘,
		‘0‘,
		‘0‘,
		‘0‘,
		‘F‘,
		‘F‘,
		‘F‘,
		‘F‘,
		‘F‘,
		‘F‘,
		‘F‘,
		‘T‘,
		‘F‘,
		‘F‘,
		#{name,jdbcType=VARCHAR},
		#{description,jdbcType=VARCHAR},
		#{x_funcheck_date,javaType=String,jdbcType=DATE,typeHandler=com.labway.portal.handler.LwDateTypeHandler},
		#{x_timecheck_date,javaType=String,jdbcType=DATE,typeHandler=com.labway.portal.handler.LwDateTypeHandler},
		#{pm_date,javaType=String,jdbcType=DATE,typeHandler=com.labway.portal.handler.LwDateTypeHandler},
		#{x_pm_status,jdbcType=VARCHAR},
		#{x_status,jdbcType=VARCHAR},
		#{x_group_name,jdbcType=VARCHAR}
		)
	</insert>


本文出自 “大话程序” 博客,请务必保留此出处http://houqida.blog.51cto.com/8877896/1584685

mybatis 插入null 时需要指定jdbcType