⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 category.xml

📁 这是一个用ibatis实现持久层的 配置文件的例子 希望对初学者有帮助。
💻 XML
字号:
<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMap      
    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"      
    "http://ibatis.apache.org/dtd/sql-map-2.dtd">
<sqlMap>

	<typeAlias alias="Category"
		type="cn.com.tarena.ecport.pojo.Category" />

	<typeAlias alias="Product" type="cn.com.tarena.ecport.pojo.Product" />

	<resultMap id="result_base" class="Category">
		<result property="categoryid" column="categoryid" />
		<result property="name" column="name" />
		<result property="description" column="description" />
		
		<result property="products" column="categoryid"
			select="findByCategoryId" />
			</resultMap>
	<select id="findAllCategory" resultClass="Category"
		resultMap="result_base">
		select * from category
	</select>
	<select id="findByCategoryId" parameterClass="Long"
		resultClass="Product">
		select * from product where categoryid=#categoryid#

	</select>
	<delete id="deleteCategoryByPojo" parameterClass="Category">
		delete from Category where categoryid = #categoryid#
	</delete>


	<select id="findById" parameterClass="Long"
		resultMap="result_base">
		select * from category where categoryid = #id#
	</select>

	<insert id="insertCategory" parameterClass="Category">
		<selectKey resultClass="long" keyProperty="categoryid">
			select studentPKSequence.nextVal from dual
		</selectKey>
		insert into category(categoryid,name,description)
		values(#categoryid#,#name#,#description#)
	</insert>
	<update id="updateCategory" parameterClass="Category">
		update category set name = #name#, description = #description#
		where categoryid = #categoryid#
	</update>
</sqlMap>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -