Package com.poscoict.glueframework.dao.mybatis
package com.poscoict.glueframework.dao.mybatis
dao package for MyBatis. Glue Data Access Object(DAO).
DAO class는 applicationContext.xml에 정의된다.
1. applicationContext.xml<bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close"> <property name="driverClassName" value="oracle.jdbc.driver.OracleDriver"/> <property name="url" value="jdbc:oracle:thin:@127.0.0.1:1521:ORCL"/> <property name="username" value="scott"/> <property name="password" value="tiger"/> <property name="defaultAutoCommit" value="false"/> </bean> <bean id="dao" class="com.poscoict.glueframework.dao.mybatis.GlueMybatisDao"> <property name="sqlSession" ref="sqlSession" /> </bean> <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg index="0" ref="sqlSessionFactory" /> </bean> <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource" /> <property name="mapperLocations" value="classpath*:mybatis/mapper/*.xml" /> </bean>
2. mybatis/mapper/{name}.xml<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="dept.mapper"> <select id="getDept" resultType="sample.vo.DeptVo"> select DEPTNO,DNAME,LOC from dept </select> <select id="getDeptbyNo" parameterType="sample.vo.DeptVo" resultType="sample.vo.DeptVo"> select DEPTNO,DNAME,LOC from dept where LOC = #{loc} </select> <delete id="delete" parameterType="sample.vo.DeptVo"> delete from dept where deptno= #{deptno} </delete> <insert id="insert" parameterType="sample.vo.DeptVo"> insert into dept (DEPTNO,DNAME,LOC) values (#{deptno},#{dname},#{loc}) </insert> <update id="update" parameterType="sample.vo.DeptVo"> update dept set DNAME=#{dname}, LOC=#{loc} where deptno=#{deptno} </update> <select id="getDeptbyNo2" resultType="sample.vo.DeptVo"> select DEPTNO,DNAME,LOC from dept where LOC = #{loc} </select> <delete id="delete2"> delete from dept where deptno= #{deptno} </delete> <insert id="insert2"> insert into dept (DEPTNO,DNAME,LOC) values (#{deptno},#{dname},#{loc}) </insert> <update id="update2"> update dept set DNAME=#{dname}, LOC=#{loc} where deptno=#{deptno} </update> </mapper>
- Since:
- 2013. 5. 10.
- Version:
- 1.0.0
- Author:
- 허 두녕
-
Classes