asp.net搭建mybatis开发环境
mybatis其实就是ibatis的升级版本不仅能在java上使用,asp.net照样可以使用mybatis来开发程序。mybatis是一个比较小巧的ORM框架,类似hibernate。自己试了一下用法和java上的mybatis差不多。这次在.net的平台上我也来小试牛刀,弄个小程序出来看看,开发之前要去mybatis官网上下载2个包。
1.asp.net版本的mybatis下载地址是http://www.mybatis.org/dotnet.html,如下图所示
如果有必要的话可以连开发文档一起下载。
2.把下面的dll文件全部拷贝出来,之后在项目里添加引用。日志的那个开发包可以不选
3.为了开发方便我这里在项目里添加了一个数据库student,并且建了一个学生表m_student
4.在项目里添加一个配置文件,这个文件存有所需要的连接配置,类似于hibernate里的方言。该文件可以从下载的包里拷贝出来使用名称为Providers.config
文件内容如下
<?xml version="1.0"?>
<providers xmlns="http://ibatis.apache.org/providers"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <clear/>
<provider
name="sqlServer1.0"
description="Microsoft SQL Server, provider V1.0.3300.0 in framework .NET V1.0"
enabled="true"
assemblyName="System.Data, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" connectionClass="System.Data.SqlClient.SqlConnection"
commandClass="System.Data.SqlClient.SqlCommand"
parameterClass="System.Data.SqlClient.SqlParameter"
parameterDbTypeClass="System.Data.SqlDbType"
parameterDbTypeProperty="SqlDbType"
dataAdapterClass="System.Data.SqlClient.SqlDataAdapter"
commandBuilderClass="System.Data.SqlClient.SqlCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix="@"
allowMARS="false"
/>
<provider
name="sqlServer1.1"
description="Microsoft SQL Server, provider V1.0.5000.0 in framework .NET V1.1"
enabled="true"
default="true"
assemblyName="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
connectionClass="System.Data.SqlClient.SqlConnection"
commandClass="System.Data.SqlClient.SqlCommand"
parameterClass="System.Data.SqlClient.SqlParameter"
parameterDbTypeClass="System.Data.SqlDbType"
parameterDbTypeProperty="SqlDbType"
dataAdapterClass="System.Data.SqlClient.SqlDataAdapter"
commandBuilderClass="System.Data.SqlClient.SqlCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix="@"
allowMARS="false"
/>
<!--SqlServer 2.0 SQl-->
<provider
name="sqlServer2.0"
enabled="true"
description="Microsoft SQL Server, provider V2.0.0.0 in framework .NET V2.0"
assemblyName="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
connectionClass="System.Data.SqlClient.SqlConnection"
commandClass="System.Data.SqlClient.SqlCommand"
parameterClass="System.Data.SqlClient.SqlParameter"
parameterDbTypeClass="System.Data.SqlDbType"
parameterDbTypeProperty="SqlDbType"
dataAdapterClass="System.Data.SqlClient.SqlDataAdapter"
commandBuilderClass=" System.Data.SqlClient.SqlCommandBuilder"
usePositionalParameters = "false"
useParameterPrefixInSql = "true"
useParameterPrefixInParameter = "true"
parameterPrefix="@"
allowMARS="false"
/> <provider name="OleDb1.1"
description="OleDb, provider V1.0.5000.0 in framework .NET V1.1"
enabled="true"
assemblyName="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
connectionClass="System.Data.OleDb.OleDbConnection"
commandClass="System.Data.OleDb.OleDbCommand"
parameterClass="System.Data.OleDb.OleDbParameter"
parameterDbTypeClass="System.Data.OleDb.OleDbType"
parameterDbTypeProperty="OleDbType"
dataAdapterClass="System.Data.OleDb.OleDbDataAdapter"
commandBuilderClass="System.Data.OleDb.OleDbCommandBuilder"
usePositionalParameters="true"
useParameterPrefixInSql="false"
useParameterPrefixInParameter="false"
parameterPrefix=""
allowMARS="false"
/>
<provider name="OleDb2.0"
description="OleDb, provider V2.0.0.0 in framework .NET V2"
enabled="false"
assemblyName="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
connectionClass="System.Data.OleDb.OleDbConnection"
commandClass="System.Data.OleDb.OleDbCommand"
parameterClass="System.Data.OleDb.OleDbParameter"
parameterDbTypeClass="System.Data.OleDb.OleDbType"
parameterDbTypeProperty="OleDbType"
dataAdapterClass="System.Data.OleDb.OleDbDataAdapter"
commandBuilderClass="System.Data.OleDb.OleDbCommandBuilder"
usePositionalParameters="true"
useParameterPrefixInSql="false"
useParameterPrefixInParameter="false"
parameterPrefix=""
allowMARS="false"
/>
<provider
name="Odbc1.1"
description="Odbc, provider V1.0.5000.0 in framework .NET V1.1"
enabled="false"
assemblyName="System.Data, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
connectionClass="System.Data.Odbc.OdbcConnection"
commandClass="System.Data.Odbc.OdbcCommand"
parameterClass="System.Data.Odbc.OdbcParameter"
parameterDbTypeClass="System.Data.Odbc.OdbcType"
parameterDbTypeProperty="OdbcType"
dataAdapterClass="System.Data.Odbc.OdbcDataAdapter"
commandBuilderClass="System.Data.Odbc.OdbcCommandBuilder"
usePositionalParameters="true"
useParameterPrefixInSql="false"
useParameterPrefixInParameter="false"
parameterPrefix="@"
allowMARS="false"
/>
<!--ODBC 2.0 Support-->
<provider
name="Odbc2.0"
description="Odbc, provider V2.0.0.0 in framework .NET V2"
enabled="false"
assemblyName="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
connectionClass="System.Data.Odbc.OdbcConnection"
commandClass="System.Data.Odbc.OdbcCommand"
parameterClass="System.Data.Odbc.OdbcParameter"
parameterDbTypeClass="System.Data.Odbc.OdbcType"
parameterDbTypeProperty="OdbcType"
dataAdapterClass="System.Data.Odbc.OdbcDataAdapter"
commandBuilderClass="System.Data.Odbc.OdbcCommandBuilder"
usePositionalParameters="true"
useParameterPrefixInSql="false"
useParameterPrefixInParameter="false"
parameterPrefix="@"
allowMARS="false"
/> <provider
name="oracle9.2"
description="Oracle, Oracle provider V9.2.0.401"
enabled="false"
assemblyName="Oracle.DataAccess, Version=9.2.0.401, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionClass="Oracle.DataAccess.Client.OracleConnection"
commandClass="Oracle.DataAccess.Client.OracleCommand"
parameterClass="Oracle.DataAccess.Client.OracleParameter"
parameterDbTypeClass="Oracle.DataAccess.Client.OracleDbType"
parameterDbTypeProperty="OracleDbType"
dataAdapterClass="Oracle.DataAccess.Client.OracleDataAdapter"
commandBuilderClass="Oracle.DataAccess.Client.OracleCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="false"
parameterPrefix=":"
useDeriveParameters="false"
allowMARS="false"
/>
<provider
name="oracle10.1"
description="Oracle, oracle provider V10.1.0.301"
enabled="false"
assemblyName="Oracle.DataAccess, Version=10.1.0.301, Culture=neutral, PublicKeyToken=89b483f429c47342" connectionClass="Oracle.DataAccess.Client.OracleConnection"
commandClass="Oracle.DataAccess.Client.OracleCommand"
parameterClass="Oracle.DataAccess.Client.OracleParameter"
parameterDbTypeClass="Oracle.DataAccess.Client.OracleDbType"
parameterDbTypeProperty="OracleDbType"
dataAdapterClass="Oracle.DataAccess.Client.OracleDataAdapter"
commandBuilderClass="Oracle.DataAccess.Client.OracleCommandBuilder"
usePositionalParameters="true"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix=":"
useDeriveParameters="false"
allowMARS="false"
/>
<!--Oracle Support-->
<provider
name="oracleClient1.0"
description="Oracle, Microsoft provider V1.0.5000.0"
enabled="false"
assemblyName="System.Data.OracleClient, Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" connectionClass="System.Data.OracleClient.OracleConnection"
commandClass="System.Data.OracleClient.OracleCommand"
parameterClass="System.Data.OracleClient.OracleParameter"
parameterDbTypeClass="System.Data.OracleClient.OracleType"
parameterDbTypeProperty="OracleType"
dataAdapterClass="System.Data.OracleClient.OracleDataAdapter"
commandBuilderClass="System.Data.OracleClient.OracleCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="false"
parameterPrefix=":"
allowMARS="false"
/>
<!--ByteFX Support-->
<provider
name="ByteFx"
description="MySQL, ByteFx provider V0.7.6.15073"
enabled="false"
assemblyName="ByteFX.MySqlClient, Version=0.7.6.15073, Culture=neutral, PublicKeyToken=f2fef6fed1732fc1" connectionClass="ByteFX.Data.MySqlClient.MySqlConnection"
commandClass="ByteFX.Data.MySqlClient.MySqlCommand"
parameterClass="ByteFX.Data.MySqlClient.MySqlParameter"
parameterDbTypeClass="ByteFX.Data.MySqlClient.MySqlDbType"
parameterDbTypeProperty="MySqlDbType"
dataAdapterClass="ByteFX.Data.MySqlClient.MySqlDataAdapter"
commandBuilderClass="ByteFX.Data.MySqlClient.MySqlCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix="@"
allowMARS="false"
/>
<!--MySql Support-->
<provider
name="MySql"
description="MySQL, MySQL provider 1.0.7.30072"
enabled="false"
assemblyName="MySql.Data, Version=1.0.7.30072, Culture=neutral, PublicKeyToken=c5687fc88969c44d" connectionClass="MySql.Data.MySqlClient.MySqlConnection"
commandClass="MySql.Data.MySqlClient.MySqlCommand"
parameterClass="MySql.Data.MySqlClient.MySqlParameter"
parameterDbTypeClass="MySql.Data.MySqlClient.MySqlDbType"
parameterDbTypeProperty="MySqlDbType"
dataAdapterClass="MySql.Data.MySqlClient.MySqlDataAdapter"
commandBuilderClass="MySql.Data.MySqlClient.MySqlCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix="?"
allowMARS="false"
/>
<!--SQLite 3 Support-->
<provider name="SQLite3"
description="SQLite, SQLite.NET provider V0.21.1869.3794"
enabled="false"
assemblyName="SQLite.NET, Version=0.21.1869.3794, Culture=neutral, PublicKeyToken=c273bd375e695f9c"
connectionClass="Finisar.SQLite.SQLiteConnection"
commandClass="Finisar.SQLite.SQLiteCommand"
parameterClass="Finisar.SQLite.SQLiteParameter"
parameterDbTypeClass="System.Data.DbType, System.Data"
parameterDbTypeProperty="DbType"
dataAdapterClass="Finisar.SQLite.SQLiteDataAdapter"
commandBuilderClass="Finisar.SQLite.SQLiteCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix="@"
setDbParameterPrecision="false"
setDbParameterScale="false"
allowMARS="false"
/>
<!--Firebird Support-->
<provider
name="Firebird1.7"
description="Firebird, Firebird SQL .NET provider V1.7.0.33200"
enabled="false"
assemblyName="FirebirdSql.Data.Firebird, Version=1.7.0.33200, Culture=neutral, PublicKeyToken=fa843d180294369d" connectionClass="FirebirdSql.Data.Firebird.FbConnection"
commandClass="FirebirdSql.Data.Firebird.FbCommand"
parameterClass="FirebirdSql.Data.Firebird.FbParameter"
parameterDbTypeClass="FirebirdSql.Data.Firebird.FbDbType"
parameterDbTypeProperty="FbDbType"
dataAdapterClass="FirebirdSql.Data.Firebird.FbDataAdapter"
commandBuilderClass="FirebirdSql.Data.Firebird.FbCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix="@"
allowMARS="false"
/>
<!--PostgreSql Support-->
<provider
name="PostgreSql0.99.1.0"
description="PostgreSql, Npgsql provider V0.99.1.0"
enabled="false"
assemblyName="Npgsql, Version=0.99.1.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7"
connectionClass="Npgsql.NpgsqlConnection"
commandClass="Npgsql.NpgsqlCommand"
parameterClass="Npgsql.NpgsqlParameter"
parameterDbTypeClass="NpgsqlTypes.NpgsqlDbType"
parameterDbTypeProperty="NpgsqlDbType"
dataAdapterClass="Npgsql.NpgsqlDataAdapter"
commandBuilderClass="Npgsql.NpgsqlCommandBuilder"
usePositionalParameters="false"
useParameterPrefixInSql="true"
useParameterPrefixInParameter="true"
parameterPrefix=":"
allowMARS="true"
/>
<!--DB2 Support-->
<provider
name="iDb2.10"
description="IBM DB2 Provider, V 10.0"
enabled="false"
assemblyName="IBM.Data.DB2.iSeries, Version=10.0.0.0,Culture=neutral, PublicKeyToken=9cdb2ebfb1f93a26, Custom=null" connectionClass="IBM.Data.DB2.iSeries.iDB2Connection"
commandClass="IBM.Data.DB2.iSeries.iDB2Command"
parameterClass="IBM.Data.DB2.iSeries.iDB2Parameter"
parameterDbTypeClass="IBM.Data.DB2.iSeries.iDB2DbType"
parameterDbTypeProperty="iDB2DbType"
dataAdapterClass="IBM.Data.DB2.iSeries.iDB2DataAdapter"
commandBuilderClass="IBM.Data.DB2.iSeries.iDB2CommandBuilder"
usePositionalParameters="true"
useParameterPrefixInSql="false"
useParameterPrefixInParameter="false"
parameterPrefix=""
allowMARS="false"
/>
<provider
name="Informix"
description="Informix NET Provider, 2.81.0.0"
enabled="false"
assemblyName="IBM.Data.Informix, Version=2.81.0.0, Culture=neutral, PublicKeyToken=7c307b91aa13d208"
connectionClass="IBM.Data.Informix.IfxConnection"
commandClass="IBM.Data.Informix.IfxCommand"
parameterClass="IBM.Data.Informix.IfxParameter"
parameterDbTypeClass="IBM.Data.Informix.IfxType"
parameterDbTypeProperty="IfxType"
dataAdapterClass="IBM.Data.Informix.IfxDataAdapter"
commandBuilderClass="IBM.Data.Informix.IfxCommandBuilder"
usePositionalParameters = "true"
useParameterPrefixInSql = "false"
useParameterPrefixInParameter = "false"
useDeriveParameters="false"
allowMARS="false"
/>
<provider
name="sqlServer2005"
enabled="true"
description="Microsoft SQL Server, provider V2.0.0.0 in framework .NET V2.0"
assemblyName="System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
connectionClass="System.Data.SqlClient.SqlConnection"
commandClass="System.Data.SqlClient.SqlCommand"
parameterClass="System.Data.SqlClient.SqlParameter"
parameterDbTypeClass="System.Data.SqlDbType"
parameterDbTypeProperty="SqlDbType"
dataAdapterClass="System.Data.SqlClient.SqlDataAdapter"
commandBuilderClass=" System.Data.SqlClient.SqlCommandBuilder"
usePositionalParameters = "false"
useParameterPrefixInSql = "true"
useParameterPrefixInParameter = "true"
parameterPrefix="@"
allowMARS="true"
/>
</providers>
最后这个是我自己加上的
5.编写持久层代码Student.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web; namespace useribatis
{
public class Student
{
public int id { set; get; }
public String username{ set; get; }
public String password{ set; get; }
}
}
6.编写mybatis的映射文件,需要注意的是名称空间要正确并且完整。我这里只写了一个比较简单的
<?xml version="1.0" encoding="utf-8" ?>
<sqlMap namespace="Student" xmlns="http://ibatis.apache.org/mapping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<statements>
<insert id="create" parameterClass="useribatis.Student">
insert into m_student(username,password)
values (#username#,#password#)
</insert>
</statements>
</sqlMap>
这里建议大家把名称空间写规范些,parameterClass的地方可以使类全名,配置文件的参数我就不在强调了。
7.编写SqlMap.config配置文件
<?xml version="1.0" encoding="utf-8"?>
<sqlMapConfig xmlns="http://ibatis.apache.org/dataMapper"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<settings>
<!-- 启用缓存 -->
<setting cacheModelsEnabled="true"/>
<!-- 配置是否使用名称空间这里建议写成true -->
<setting useStatementNamespaces="true" /> </settings>
<!-- 引入providers配置文件 -->
<providers resource="providers.config"/>
<database>
<provider name="sqlServer2005" />
<!-- 配置连接字符串 -->
<dataSource name="SqlServer" connectionString="data source=.\SQLEXPRESS;AttachDbFilename=G:\source\useribatis\useribatis\App_Data\Student.mdf;Integrated Security=True;User Instance=True;" />
</database> <sqlMaps>
<!-- 映射的资源文件 -->
<sqlMap resource="Maps/StudentInfo.xml"/>
</sqlMaps> </sqlMapConfig>
8.编写一个类用来插入数据
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using IBatisNet.Common; using IBatisNet.DataMapper; using IBatisNet.DataMapper.Configuration; using IBatisNet.Common.Utilities; using IBatisNet.DataAccess; using IBatisNet.DataAccess.Configuration; using IBatisNet.DataAccess.Interfaces; using IBatisNet.Common.Logging;
namespace useribatis
{
public class Insert
{
public void doCreate() {
DomSqlMapBuilder builder = new DomSqlMapBuilder();
ISqlMapper Map = builder.Configure("SqlMap.config");
// SqlMapper sqlMapper = builder.Configure() as SqlMapper;
Student stu=new Student();
stu.username="李敏镐3";
stu.password="1234567"; Map.Insert("Student.create", stu);
} }
}
9.创建单元测试,查看程序是否正确如下所示
之后选择要测试的方法
点击确定,visual studio就会为我们创建单元测试了。之后为单元测试生成以下解决方案,之后就打开测试窗口
下面就可以开始单元测试了,如下所示点击之后运行选定内容
执行完成后来看下数据库是否生成了数据
如果程序出错了可以像下面这样做查看异常信息
到这里程序就写好了,下面我贴一个映射文件出来大家以后开发可以模仿着下面的这个写,注意下名称空间的区别就好
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sqlMap
PUBLIC "-//iBATIS.com//DTD SQL Map 2.0//EN"
"http://www.ibatis.com/dtd/sql-map-2.dtd">
<sqlMap namespace="Course"> <resultMap id="resultMap" class="com.junze.huiju.module.course.info.CourseInfo">
<result property="REMARK1" column="REMARK1"/>
<result property="FCOURSENATURE" column="FCOURSENATURE"/>
<result property="REMARK2" column="REMARK2"/>
<result property="FCOURSENUM" column="FCOURSENUM"/>
<result property="FID" column="FID"/>
<result property="FNAME" column="FNAME"/>
</resultMap> <sql id="sqlwhere">
<dynamic>
<isNotEmpty prepend="and" property="REMARK1">
A.REMARK1 like #REMARK1#
</isNotEmpty>
<isGreaterThan prepend="and" property="FCOURSENATURE" compareValue="0">
A.FCOURSENATURE = #FCOURSENATURE#
</isGreaterThan>
<isNotEmpty prepend="and" property="REMARK2">
A.REMARK2 like #REMARK2#
</isNotEmpty>
<isGreaterThan prepend="and" property="FCOURSENUM" compareValue="0">
A.FCOURSENUM = #FCOURSENUM#
</isGreaterThan>
<isGreaterThan prepend="and" property="FID" compareValue="0">
A.FID = #FID#
</isGreaterThan>
<isNotEmpty prepend="and" property="FNAME">
A.FNAME like #FNAME#
</isNotEmpty>
<isNotEmpty prepend="and" property="containIds">
A.FID NOT IN ($containIds$)
</isNotEmpty>
</dynamic>
</sql> <!--getInfoByID-->
<select id="getInfoByID" resultMap="resultMap" parameterClass="int">
select A.*
from M_COURSE A where A.FID = #id#
</select> <!--read-->
<select id="read" resultMap="resultMap" parameterClass="com.junze.huiju.module.course.info.CourseInfo">
select A.*
from M_COURSE A where 1=1
<include refid="sqlwhere"/>
</select> <!--getlist-->
<select id="getList" resultMap="resultMap" parameterClass="com.junze.huiju.module.course.info.CourseInfo">
select * from (select rownum numrow ,A.* from (select A.*
from M_COURSE A where 1=1
<include refid="sqlwhere"/>
Order By A.FID
) A) where numrow > $startRow$ and numrow < $endRow$
</select> <!--getAlllist-->
<select id="getAllList" resultMap="resultMap" parameterClass="com.junze.huiju.module.course.info.CourseInfo">
select A.*
from M_COURSE A where 1=1
<include refid="sqlwhere"/>
Order By A.FID Desc
</select> <!--getBusinessList-->
<select id="getBusinessList" resultMap="resultMap" parameterClass="com.junze.huiju.module.course.info.CourseInfo">
select A.*
from M_COURSE A where 1=1
<include refid="sqlwhere"/>
Order By A.FID Desc
</select> <!--getCount-->
<select id="getCount" resultClass="java.lang.Integer" parameterClass="com.junze.huiju.module.course.info.CourseInfo">
select count(*) from M_COURSE A where 1=1
<include refid="sqlwhere"/>
</select> <!--create-->
<insert id="create" parameterClass="com.junze.huiju.module.course.info.CourseInfo">
<selectKey resultClass="int" keyProperty="FID">
select SEQ_M_COURSE.nextVal as value from dual
</selectKey>
insert into M_COURSE(REMARK1,FCOURSENATURE,REMARK2,FCOURSENUM,FID,FNAME)
values (#REMARK1:VARCHAR2#,#FCOURSENATURE#,#REMARK2:VARCHAR2#,#FCOURSENUM#,#FID#,#FNAME:VARCHAR2#)
</insert> <!--update -->
<update id="update" parameterClass="com.junze.huiju.module.course.info.CourseInfo">
update M_COURSE set REMARK1= #REMARK1:VARCHAR2#,
FCOURSENATURE = #FCOURSENATURE#,
REMARK2 = #REMARK2:VARCHAR2#,
FCOURSENUM = #FCOURSENUM#,
FID = #FID#,
FNAME = #FNAME:VARCHAR2#
where FID = #FID#
</update> <!--deleteByID-->
<delete id="deleteByID" parameterClass="int">
delete from M_COURSE where FID = #id#
</delete> <!--deleteByCondition-->
<delete id="deleteByCondition" parameterClass="com.junze.huiju.module.course.info.CourseInfo">
delete from M_COURSE A where 1=1
<include refid="sqlwhere"/>
</delete> </sqlMap>
想这样的配置文件应该算是比较完整的了,大家练习一下吧。代码在我的资源里大家自己去下载。如果有写的不对的大家可以拍砖。
asp.net搭建mybatis开发环境的更多相关文章
- 搭建MyBatis开发环境及基本的CURD
目录 一.MyBatis概述 1. MyBatis 解决的主要问题 二.快速开始一个 MyBatis 1. 创建mysql数据库和表 2. 创建maven工程 3. 在pom.xml文件中添加信息 4 ...
- 搭建mybatis开发环境
1.创建工程 <groupId>com.hope</groupId> <artifactId>day01_eesy_01mybatis</artifa ...
- MyBatis01 Idea中搭建MyBatis开发环境
项目结构 POM模板 <?xml version="1.0" encoding="UTF-8"?> <project xmlns=" ...
- 抛弃强大的TFS ,借助于BugTracker.NET + Visual Source Safe + SourceLink搭建项目开发环境
微软公司的Team Foundation Server是个强大的项目管理工具,如果用.NET开发,它应该是首选的项目管理平台.TFS的成本比较高,而且和Visual Studio集成紧密.比如TSF有 ...
- VS Code搭建.NetCore开发环境(一)
一.使用命令创建并运行.Net Core程序 1.dotnet new xxx:创建指定类型的项目console,mvc,webapi 等 2.dotnet restore :加载依赖项 dotne ...
- 搭建SpriBoot开发环境
一.搭建springboot开发环境 需求:使用springboot搭建一个项目,编写一个controller控制器,使用浏览器正常访问 springboot1.x版本--> 基于sprin ...
- 自定义搭建PHP开发环境
学习了一段时间php了,因为之前是刚接触php,所以用的是集成安装包(wamp).现在想进一步了解apache.mysql.php之间的关系以及提升自己所以进行自定义搭建PHP开发环境.废话不多说,请 ...
- 使用virtualenv搭建python3开发环境
问题描述 环境: CentOS6.5 想在此环境下使用python3进行开发,但CentOS6.5默认的python环境是2.6.6版本. 之前的做法是直接从源码安装python3,替换掉现有的开发环 ...
- Windows下搭建PHP开发环境
PHP集成开发环境有很多,如XAMPP.AppServ......只要一键安装就把PHP环境给搭建好了.但这种安装方式不够灵活,软件的自由组合不方便,同时也不利于学习.所以我还是喜欢手工搭建PHP开发 ...
随机推荐
- ios开发周期之--(向上,向下,四舍五入)取整
ceil(x)返回不小于x的最小整数值(然后转换为double型). floor(x)返回不大于x的最大整数值. round(x)返回x的四舍五入整数值.
- TCP三次握手原则
“已失效的连接请求报文段”的产生在这样一种情况下: client发出的第一个连接请求报文段并没有丢失,而是在某个网络结点长时间的滞留了,以致延误到连接释放以后的某个时间才到达server. 本来这是一 ...
- 【RF库Collections测试】Reverse List
Name:Reverse ListSource:Collections <test library>Arguments:[ list_ ]Reverses the given list i ...
- U3D功能脚本备忘
编译器属性 属性 介绍 用例 AddComponentMenu 在Component菜单中添加新的菜单项 [AddComponentMenu("Duan/Script/TestScript& ...
- 一个汉字转拼音的php类
代码来自网上,可用 <?php function Pinyin($_String, $_Code='gb2312') { $_DataKey = "a|ai|an|ang|ao|ba| ...
- creat-react-app 如何在组件中img的src引入图片路径??
把图片文件夹放到public中,然后以这种方式来动态写路径: process.env.PUBLIC_URL + '/img/' + url + '.jpg'
- hadoop自动提交脚本
自动提交到hadoop系统,然后调用wordcount的任务,并下载输出的文件. #!/bin/sh #从给定的路径获取文件列表,提交到hadoop系统,使用wordcount的功能统计单词数量 #e ...
- VMware Workstation 14 黑屏的一个解决办法
近期很多朋友遇到了VMware Workstation 14开启或新建虚拟机后黑屏的现象,同时发现如果挂起虚拟机,可以显示挂起前最后的画面.显然,虚拟机核心是正常工作的,只是“显示”方面出现了问题. ...
- 微信小程序学习指南
作者:初雪链接:https://www.zhihu.com/question/50907897/answer/128494332来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注明 ...
- Objective-C官方文档 协议
版权声明:原创作品,谢绝转载!否则将追究法律责任. 在现实生活中,当处理某一情况的时候人们往往遵循严格的程序.执法人员他们在打官司的收集证据和询问的时候一定要遵守协议. 在面向对象的语言中,最重要的是 ...