Mybatis alias

Introduced: before writing a type in the mapping file [mapper file = sql mapping file], you must write the fully qualified name-after configuring the alias, the type can be abbreviated

  1. How to configure: configure
    in the main configuration file of mybatis
	<!-- 配置别名  -->
<typeAliases>
	<!-- 这个包下面的类都可以写简写:要么直接写类名  ,要么写类名的首字母小写 -->
	<package name="cn.itsource.domain"/>
</typeAliases>
  1. Use an alias directly in the mapper mapping file
	//没有使用别名
	<select id="get" parameterType="long" resultType="it.show.domain.Product">
		select * from product where id = #{id}
	</select>
	//使用别名
	<select id="get" parameterType="long" resultType="product">
		select * from product where id = #{id}
	</select>
Published 23 original articles · praised 1 · visits 176

Guess you like

Origin blog.csdn.net/weixin_45528650/article/details/105425334