`
Xgw123485
  • 浏览: 85096 次
  • 性别: Icon_minigender_1
  • 来自: 深圳
社区版块
存档分类
最新评论

S2Si实例2

 
阅读更多
SqlMapConfig的配置文件内容:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMapConfig     
    PUBLIC "-//ibatis.apache.org//DTD SQL Map Config 2.0//EN"     
    "http://ibatis.apache.org/dtd/sql-map-config-2.dtd">

<sqlMapConfig>

<!-- Configure a built-in transaction manager. If you're using an app server,
you probably want to use its transaction manager and a managed datasource -->
<!--<transactionManager type="JDBC" commitRequired="false">
<dataSource type="SIMPLE">
<property name="JDBC.Driver" value="oracle.jdbc.driver.OracleDriver" />
<property name="JDBC.ConnectionURL" value="jdbc:oracle:thin:@localhost:1521:ESB" />
<property name="JDBC.Username" value="system" />
<property name="JDBC.Password" value="ngbss" />
</dataSource>
</transactionManager>

--><!-- List the SQL Map XML files. They can be loaded from the classpath,
as they are here (com.domain.data...) -->
<sqlMap resource="User.xml" />
<!-- List more here... <sqlMap resource="com/mydomain/data/Order.xml"/>
<sqlMap resource="com/mydomain/data/Documents.xml"/> -->

</sqlMapConfig>

User.xml的sql语句文件内容:
<?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 namespace="User">
<typeAlias alias="UserVo" type="com.huawei.ngbss.vo.User" />

<resultMap class="UserVo" id="UserResult">
<result property="s_id" column="S_ID" />
<result property="c_id" column="C_ID" />
<result property="s_name" column="S_NAME" />

</resultMap>

<!--  select all User-->
<select id="selectAllUser" resultMap="UserResult">
select * from T_Stu
</select>

<!-- select one user by Id -->
<select id="selectUserById" parameterClass="String" resultClass="UserVo">
  select * from T_Stu where s_id=#s_id#
</select>

<!-- insert a new user -->
<insert id="insertNewUser" parameterClass="UserVo">
insert into T_Stu (s_id,c_id,s_name) values(#s_id#,#c_id#,#s_name#)
</insert>

<!-- update one user by id-->
<update id="updateUserInfo" parameterClass="UserVo">
update T_Stu set s_id=#s_id#,c_id=#c_id#,s_name=#s_name# where s_id=#s_id#
</update>

<delete id="deleteUserByid" parameterClass="String">
delete from T_Stu where s_id=#s_id#
</delete>

</sqlMap>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics