1.分析目录结构“tools”(或者说模板)

2.首先分析ibatorConfig.xml文件

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE ibatorConfiguration PUBLIC "-//Apache Software Foundation//DTD Apache iBATIS Ibator Configuration 1.0//EN" "http://ibatis.apache.org/dtd/ibator-config_1_0.dtd" >
  3. <ibatorConfiguration>
  4.  
  5. <classPathEntry
  6. location="F:\sqljdbc.jar" />
  7. <ibatorContext id="context1" targetRuntime="Ibatis2Java5">
  8.  
  9. <!--
  10. classPathEntry 指定数据库jdbc驱动jar包的绝对路径。
  11. -->
  12.  
  13. <!--
  14. id 这个id可以在使用命令行运行Abator时指定,以单独处理某一个ibatorContext targetRuntime
  15. Ibatis2Java5 生成适合JDK5.0的类,另一个选项是 Ibatis2Java2,生成适合Java2的类。
  16. -->
  17.  
  18. <ibatorPlugin
  19. type="org.apache.ibatis.ibator.plugins.RenameExampleClassPlugin">
  20. <property name="searchString" value="Example$" />
  21. <property name="replaceString" value="Example" />
  22. </ibatorPlugin>
  23.  
  24. <!--
  25. ibatorPlugin 继承自IbatorPluginAdapter,包名必须是
  26. org.apache.ibatis.ibator.plugins,具体实现可以参考官方文档 必须有替换和被替换字符属性。
  27. -->
  28. <!--
  29. <jdbcConnection driverClass="org.postgresql.Driver"
  30. connectionURL="jdbc:postgresql://127.0.0.1:5432/hibernateTest" userId="postgres"
  31. password="postgres" />
  32. -->
  33. <jdbcConnection driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"
  34. connectionURL="jdbc:sqlserver://127.0.0.1:1433;databaseName=PanaDatabase" userId="sa"
  35. password="sasa" />
  36.  
  37. <!--
  38. driverClass 数据库驱动类 connectionURL 数据库连接地址 userId 用户 password 密码
  39.  
  40. 还可以使用以下格式添加数据库的其他连接属性 <property name="" value=""/>
  41. -->
  42.  
  43. <javaTypeResolver>
  44.  
  45. <property name="forceBigDecimals" value="false" />
  46.  
  47. <!--
  48. 默认false,把JDBC DECIMAL 和 NUMERIC 类型解析为 Integer true,把JDBC DECIMAL 和
  49. NUMERIC 类型解析为java.math.BigDecimal
  50. -->
  51.  
  52. </javaTypeResolver>
  53.  
  54. <javaModelGenerator targetPackage="abator.model"
  55. targetProject="comboFramework/tools" />
  56.  
  57. <!--
  58. targetProject 生成的Java Bean放置在哪个项目的哪个目录下 targetPackage 生成的Java Bean的包名
  59. 一个有用的属性 <property name="trimStrings" value="true" /> 从数据库返回的值被清理前后的空格
  60. <property name="enableSubPackages" value="false" /> 是否在包名后加上scheme名称
  61. -->
  62.  
  63. <sqlMapGenerator targetPackage="abator.sqlmap"
  64. targetProject="comboFramework/tools" />
  65.  
  66. <!--
  67. targetProject 生成的 SqlMap.xml 文件放置在哪个项目的哪个目录下 targetPackage 生成的
  68. SqlMap.xml 文件的包名 <property name="enableSubPackages" value="false" />
  69. 是否在包名后加上scheme名称
  70. -->
  71.  
  72. <daoGenerator targetPackage="abator.dao" targetProject="comboFramework/tools"
  73. type="GENERIC-CI" />
  74.  
  75. <table tableName="InfoVoteItm"></table>
  76.  
  77. </ibatorContext>
  78. </ibatorConfiguration>

需要注意的几点是

1.指向的jdbc包是否正确或存在

  1. <classPathEntry
  2. location="F:\sqljdbc.jar" />
  3. <ibatorContext id="context1" targetRuntime="Ibatis2Java5">

2.数据库连接是否配置正确

  1. <jdbcConnection driverClass="com.microsoft.sqlserver.jdbc.SQLServerDriver"
  2. connectionURL="jdbc:sqlserver://127.0.0.1:1433;databaseName=PanaDatabase" userId="sa"
  3. password="sasa" />

3.指向的模板工具是否正确

  1. <!--
  2. targetProject 生成的Java Bean放置在哪个项目的哪个目录下 targetPackage 生成的Java Bean的包名
  3. 一个有用的属性 <property name="trimStrings" value="true" /> 从数据库返回的值被清理前后的空格
  4. <property name="enableSubPackages" value="false" /> 是否在包名后加上scheme名称
  5. -->
  6.  
  7. <sqlMapGenerator targetPackage="abator.sqlmap"
  8. targetProject="comboFramework/tools" />
  9.  
  10. <!--
  11. targetProject 生成的 SqlMap.xml 文件放置在哪个项目的哪个目录下 targetPackage 生成的
  12. SqlMap.xml 文件的包名 <property name="enableSubPackages" value="false" />
  13. 是否在包名后加上scheme名称
  14. -->
  15.  
  16. <daoGenerator targetPackage="abator.dao" targetProject="comboFramework/tools"
  17. type="GENERIC-CI" />

4.指向需要生成的表

  1. <table tableName="InfoVoteItm"></table>

这里是单表(还没试过多个表一起生成呢,可以试试)

最终生成的结果如图

可以看出对iBATIS对表InfoVoteItm生成了三个模块即"sqlmap","model","dao"。

现在我们一个一个的来分析这三个部分。

在分析之前了解下InfoVoteItm表的结构

  1. USE [PanaDatabase]
  2. GO
  3. /****** 对象: Table [dbo].[InfoVoteItm] 脚本日期: 06/04/2012 16:22:55 ******/
  4. SET ANSI_NULLS ON
  5. GO
  6. SET QUOTED_IDENTIFIER ON
  7. GO
  8. CREATE TABLE [dbo].[InfoVoteItm](
  9. [EmpID] [nvarchar](250) COLLATE Chinese_PRC_CI_AS NULL,
  10. [InfoDetail_ID] [int] NULL,
  11. [VoteItmDate] [datetime] NULL CONSTRAINT [DF_InfoVoteItm_VoteItmDate] DEFAULT (getdate())
  12. ) ON [PRIMARY]

A.首先我们来分析"sqlmap"这一部分对InfoVoteItm表生成的文件InfoVoteItm_SqlMap.xml

  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <!DOCTYPE sqlMap PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN" "http://ibatis.apache.org/dtd/sql-map-2.dtd" >
  3. <sqlMap namespace="InfoVoteItm" >
  4. <resultMap id="ibatorgenerated_BaseResultMap" class="abator.model.Infovoteitm" >
  5. <!--
  6. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  7. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  8. -->
  9. <result column="EmpID" property="empid" jdbcType="VARCHAR" />
  10. <result column="InfoDetail_ID" property="infodetailId" jdbcType="INTEGER" />
  11. <result column="VoteItmDate" property="voteitmdate" jdbcType="TIMESTAMP" />
  12. </resultMap>
  13. <sql id="ibatorgenerated_Example_Where_Clause" >
  14. <!--
  15. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  16. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  17. -->
  18. <iterate property="oredCriteria" conjunction="or" prepend="where" removeFirstPrepend="iterate" >
  19. <isEqual property="oredCriteria[].valid" compareValue="true" >
  20. (
  21. <iterate prepend="and" property="oredCriteria[].criteriaWithoutValue" conjunction="and" >
  22. $oredCriteria[].criteriaWithoutValue[]$
  23. </iterate>
  24. <iterate prepend="and" property="oredCriteria[].criteriaWithSingleValue" conjunction="and" >
  25. $oredCriteria[].criteriaWithSingleValue[].condition$
  26. #oredCriteria[].criteriaWithSingleValue[].value#
  27. </iterate>
  28. <iterate prepend="and" property="oredCriteria[].criteriaWithListValue" conjunction="and" >
  29. $oredCriteria[].criteriaWithListValue[].condition$
  30. <iterate property="oredCriteria[].criteriaWithListValue[].values" open="(" close=")" conjunction="," >
  31. #oredCriteria[].criteriaWithListValue[].values[]#
  32. </iterate>
  33. </iterate>
  34. <iterate prepend="and" property="oredCriteria[].criteriaWithBetweenValue" conjunction="and" >
  35. $oredCriteria[].criteriaWithBetweenValue[].condition$
  36. #oredCriteria[].criteriaWithBetweenValue[].values[0]# and
  37. #oredCriteria[].criteriaWithBetweenValue[].values[1]#
  38. </iterate>
  39. )
  40. </isEqual>
  41. </iterate>
  42. </sql>
  43. <select id="ibatorgenerated_selectByExample" resultMap="ibatorgenerated_BaseResultMap" parameterClass="abator.model.InfovoteitmExample" >
  44. <!--
  45. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  46. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  47. -->
  48. select EmpID, InfoDetail_ID, VoteItmDate
  49. from InfoVoteItm
  50. <isParameterPresent >
  51. <include refid="InfoVoteItm.ibatorgenerated_Example_Where_Clause" />
  52. <isNotNull property="orderByClause" >
  53. order by $orderByClause$
  54. </isNotNull>
  55. </isParameterPresent>
  56. </select>
  57. <delete id="ibatorgenerated_deleteByExample" parameterClass="abator.model.InfovoteitmExample" >
  58. <!--
  59. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  60. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  61. -->
  62. delete from InfoVoteItm
  63. <include refid="InfoVoteItm.ibatorgenerated_Example_Where_Clause" />
  64. </delete>
  65. <insert id="ibatorgenerated_insert" parameterClass="abator.model.Infovoteitm" >
  66. <!--
  67. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  68. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  69. -->
  70. insert into InfoVoteItm (EmpID, InfoDetail_ID, VoteItmDate)
  71. values (#empid:VARCHAR#, #infodetailId:INTEGER#, #voteitmdate:TIMESTAMP#)
  72. </insert>
  73. <insert id="ibatorgenerated_insertSelective" parameterClass="abator.model.Infovoteitm" >
  74. <!--
  75. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  76. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  77. -->
  78. insert into InfoVoteItm
  79. <dynamic prepend="(" >
  80. <isNotNull prepend="," property="empid" >
  81. EmpID
  82. </isNotNull>
  83. <isNotNull prepend="," property="infodetailId" >
  84. InfoDetail_ID
  85. </isNotNull>
  86. <isNotNull prepend="," property="voteitmdate" >
  87. VoteItmDate
  88. </isNotNull>
  89. )
  90. </dynamic>
  91. values
  92. <dynamic prepend="(" >
  93. <isNotNull prepend="," property="empid" >
  94. #empid:VARCHAR#
  95. </isNotNull>
  96. <isNotNull prepend="," property="infodetailId" >
  97. #infodetailId:INTEGER#
  98. </isNotNull>
  99. <isNotNull prepend="," property="voteitmdate" >
  100. #voteitmdate:TIMESTAMP#
  101. </isNotNull>
  102. )
  103. </dynamic>
  104. </insert>
  105. <select id="ibatorgenerated_countByExample" parameterClass="abator.model.InfovoteitmExample" resultClass="java.lang.Integer" >
  106. <!--
  107. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  108. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  109. -->
  110. select count(*) from InfoVoteItm
  111. <include refid="InfoVoteItm.ibatorgenerated_Example_Where_Clause" />
  112. </select>
  113. <update id="ibatorgenerated_updateByExampleSelective" >
  114. <!--
  115. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  116. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  117. -->
  118. update InfoVoteItm
  119. <dynamic prepend="set" >
  120. <isNotNull prepend="," property="record.empid" >
  121. EmpID = #record.empid:VARCHAR#
  122. </isNotNull>
  123. <isNotNull prepend="," property="record.infodetailId" >
  124. InfoDetail_ID = #record.infodetailId:INTEGER#
  125. </isNotNull>
  126. <isNotNull prepend="," property="record.voteitmdate" >
  127. VoteItmDate = #record.voteitmdate:TIMESTAMP#
  128. </isNotNull>
  129. </dynamic>
  130. <isParameterPresent >
  131. <include refid="InfoVoteItm.ibatorgenerated_Example_Where_Clause" />
  132. </isParameterPresent>
  133. </update>
  134. <update id="ibatorgenerated_updateByExample" >
  135. <!--
  136. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  137. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  138. -->
  139. update InfoVoteItm
  140. set EmpID = #record.empid:VARCHAR#,
  141. InfoDetail_ID = #record.infodetailId:INTEGER#,
  142. VoteItmDate = #record.voteitmdate:TIMESTAMP#
  143. <isParameterPresent >
  144. <include refid="InfoVoteItm.ibatorgenerated_Example_Where_Clause" />
  145. </isParameterPresent>
  146. </update>
  147. </sqlMap>

可以看出对表InfoVoteItm做了实体映射(实现增加add,删除delete,修改update,查询select)

首先分析下映射实体类

  1. <resultMap id="ibatorgenerated_BaseResultMap" class="abator.model.Infovoteitm" >
  2. <!--
  3. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  4. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  5. -->
  6. <result column="EmpID" property="empid" jdbcType="VARCHAR" />
  7. <result column="InfoDetail_ID" property="infodetailId" jdbcType="INTEGER" />
  8. <result column="VoteItmDate" property="voteitmdate" jdbcType="TIMESTAMP" />
  9. </resultMap>

其中"id"起标识的作用,"class"映射由iBATIS生成的实体类(路径指向,若要移动该文件此处要及得修改)

"column"可以随意定义但前提是实体类中有相匹配的字段即"property","jdbcType"设置字段属性(属性与数据库字段类型相同)

查询(可以看出resultMap是对实体类的一种映射,如果查询select中的字段在实体类中未定义则会出现异常,parameterClass指向的是参数需要注意与class的区别)

  1. <select id="ibatorgenerated_selectByExample" resultMap="ibatorgenerated_BaseResultMap" parameterClass="abator.model.InfovoteitmExample" >
  2. <!--
  3. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  4. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  5. -->
  6. select EmpID, InfoDetail_ID, VoteItmDate
  7. from InfoVoteItm
  8. <isParameterPresent >
  9. <include refid="InfoVoteItm.ibatorgenerated_Example_Where_Clause" />
  10. <isNotNull property="orderByClause" >
  11. order by $orderByClause$
  12. </isNotNull>
  13. </isParameterPresent>
  14. </select>

查询返回结果值

  1. <select id="ibatorgenerated_countByExample" parameterClass="abator.model.InfovoteitmExample" resultClass="java.lang.Integer" >
  2. <!--
  3. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  4. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  5. -->
  6. select count(*) from InfoVoteItm
  7. <include refid="InfoVoteItm.ibatorgenerated_Example_Where_Clause" />
  8. </select>

删除

  1. <delete id="ibatorgenerated_deleteByExample" parameterClass="abator.model.InfovoteitmExample" >
  2. <!--
  3. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  4. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  5. -->
  6. delete from InfoVoteItm
  7. <include refid="InfoVoteItm.ibatorgenerated_Example_Where_Clause" />
  8. </delete>

添加

1.添加所有项

  1. <insert id="ibatorgenerated_insert" parameterClass="abator.model.Infovoteitm" >
  2. <!--
  3. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  4. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  5. -->
  6. insert into InfoVoteItm (EmpID, InfoDetail_ID, VoteItmDate)
  7. values (#empid:VARCHAR#, #infodetailId:INTEGER#, #voteitmdate:TIMESTAMP#)
  8. </insert>

2.选择性添加

  1. <insert id="ibatorgenerated_insertSelective" parameterClass="abator.model.Infovoteitm" >
  2. <!--
  3. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  4. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  5. -->
  6. insert into InfoVoteItm
  7. <dynamic prepend="(" >
  8. <isNotNull prepend="," property="empid" >
  9. EmpID
  10. </isNotNull>
  11. <isNotNull prepend="," property="infodetailId" >
  12. InfoDetail_ID
  13. </isNotNull>
  14. <isNotNull prepend="," property="voteitmdate" >
  15. VoteItmDate
  16. </isNotNull>
  17. )
  18. </dynamic>
  19. values
  20. <dynamic prepend="(" >
  21. <isNotNull prepend="," property="empid" >
  22. #empid:VARCHAR#
  23. </isNotNull>
  24. <isNotNull prepend="," property="infodetailId" >
  25. #infodetailId:INTEGER#
  26. </isNotNull>
  27. <isNotNull prepend="," property="voteitmdate" >
  28. #voteitmdate:TIMESTAMP#
  29. </isNotNull>
  30. )
  31. </dynamic>
  32. </insert>

变更

1.选择性变更(条件可选)

  1. <update id="ibatorgenerated_updateByExampleSelective" >
  2. <!--
  3. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  4. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  5. -->
  6. update InfoVoteItm
  7. <dynamic prepend="set" >
  8. <isNotNull prepend="," property="record.empid" >
  9. EmpID = #record.empid:VARCHAR#
  10. </isNotNull>
  11. <isNotNull prepend="," property="record.infodetailId" >
  12. InfoDetail_ID = #record.infodetailId:INTEGER#
  13. </isNotNull>
  14. <isNotNull prepend="," property="record.voteitmdate" >
  15. VoteItmDate = #record.voteitmdate:TIMESTAMP#
  16. </isNotNull>
  17. </dynamic>
  18. <isParameterPresent >
  19. <include refid="InfoVoteItm.ibatorgenerated_Example_Where_Clause" />
  20. </isParameterPresent>
  21. </update>

2.条件必须

  1. <update id="ibatorgenerated_updateByExample" >
  2. <!--
  3. WARNING - This element is automatically generated by Apache iBATIS ibator, do not modify.
  4. This element was generated on Wed Mar 09 16:57:25 CST 2011.
  5. -->
  6. update InfoVoteItm
  7. set EmpID = #record.empid:VARCHAR#,
  8. InfoDetail_ID = #record.infodetailId:INTEGER#,
  9. VoteItmDate = #record.voteitmdate:TIMESTAMP#
  10. <isParameterPresent >
  11. <include refid="InfoVoteItm.ibatorgenerated_Example_Where_Clause" />
  12. </isParameterPresent>
  13. </update>

"model"是对实体类的封装就不说了,看下"dao"层。

"dao"层生成了两个文件InfovoteitmDAO是接口类对方法的声明(包括增,删,改,查)而InfovoteitmDAOImpl是类是对InfovoteitmDAO接口方法的

实现。

  1. InfovoteitmDAO 接口
  1. package abator.dao;
  2.  
  3. import abator.model.Infovoteitm;
  4. import abator.model.InfovoteitmExample;
  5. import java.sql.SQLException;
  6. import java.util.List;
  7.  
  8. public interface InfovoteitmDAO {
  9. /**
  10. * This method was generated by Apache iBATIS ibator.
  11. * This method corresponds to the database table InfoVoteItm
  12. *
  13. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  14. */
  15. int countByExample(InfovoteitmExample example) throws SQLException;
  16.  
  17. /**
  18. * This method was generated by Apache iBATIS ibator.
  19. * This method corresponds to the database table InfoVoteItm
  20. *
  21. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  22. */
  23. int deleteByExample(InfovoteitmExample example) throws SQLException;
  24.  
  25. /**
  26. * This method was generated by Apache iBATIS ibator.
  27. * This method corresponds to the database table InfoVoteItm
  28. *
  29. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  30. */
  31. void insert(Infovoteitm record) throws SQLException;
  32.  
  33. /**
  34. * This method was generated by Apache iBATIS ibator.
  35. * This method corresponds to the database table InfoVoteItm
  36. *
  37. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  38. */
  39. void insertSelective(Infovoteitm record) throws SQLException;
  40.  
  41. /**
  42. * This method was generated by Apache iBATIS ibator.
  43. * This method corresponds to the database table InfoVoteItm
  44. *
  45. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  46. */
  47. List<Infovoteitm> selectByExample(InfovoteitmExample example) throws SQLException;
  48.  
  49. /**
  50. * This method was generated by Apache iBATIS ibator.
  51. * This method corresponds to the database table InfoVoteItm
  52. *
  53. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  54. */
  55. int updateByExampleSelective(Infovoteitm record, InfovoteitmExample example) throws SQLException;
  56.  
  57. /**
  58. * This method was generated by Apache iBATIS ibator.
  59. * This method corresponds to the database table InfoVoteItm
  60. *
  61. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  62. */
  63. int updateByExample(Infovoteitm record, InfovoteitmExample example) throws SQLException;
  64. }

InfovoteitmDAOImpl类

  1. package abator.dao;
  2.  
  3. import abator.model.Infovoteitm;
  4. import abator.model.InfovoteitmExample;
  5. import com.ibatis.sqlmap.client.SqlMapClient;
  6. import java.sql.SQLException;
  7. import java.util.List;
  8.  
  9. public class InfovoteitmDAOImpl implements InfovoteitmDAO {
  10. /**
  11. * This field was generated by Apache iBATIS ibator.
  12. * This field corresponds to the database table InfoVoteItm
  13. *
  14. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  15. */
  16. private SqlMapClient sqlMapClient;
  17.  
  18. /**
  19. * This method was generated by Apache iBATIS ibator.
  20. * This method corresponds to the database table InfoVoteItm
  21. *
  22. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  23. */
  24. public InfovoteitmDAOImpl(SqlMapClient sqlMapClient) {
  25. super();
  26. this.sqlMapClient = sqlMapClient;
  27. }
  28.  
  29. /**
  30. * This method was generated by Apache iBATIS ibator.
  31. * This method corresponds to the database table InfoVoteItm
  32. *
  33. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  34. */
  35. public int countByExample(InfovoteitmExample example) throws SQLException {
  36. Integer count = (Integer) sqlMapClient.queryForObject("InfoVoteItm.ibatorgenerated_countByExample", example);
  37. return count;
  38. }
  39.  
  40. /**
  41. * This method was generated by Apache iBATIS ibator.
  42. * This method corresponds to the database table InfoVoteItm
  43. *
  44. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  45. */
  46. public int deleteByExample(InfovoteitmExample example) throws SQLException {
  47. int rows = sqlMapClient.delete("InfoVoteItm.ibatorgenerated_deleteByExample", example);
  48. return rows;
  49. }
  50.  
  51. /**
  52. * This method was generated by Apache iBATIS ibator.
  53. * This method corresponds to the database table InfoVoteItm
  54. *
  55. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  56. */
  57. public void insert(Infovoteitm record) throws SQLException {
  58. sqlMapClient.insert("InfoVoteItm.ibatorgenerated_insert", record);
  59. }
  60.  
  61. /**
  62. * This method was generated by Apache iBATIS ibator.
  63. * This method corresponds to the database table InfoVoteItm
  64. *
  65. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  66. */
  67. public void insertSelective(Infovoteitm record) throws SQLException {
  68. sqlMapClient.insert("InfoVoteItm.ibatorgenerated_insertSelective", record);
  69. }
  70.  
  71. /**
  72. * This method was generated by Apache iBATIS ibator.
  73. * This method corresponds to the database table InfoVoteItm
  74. *
  75. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  76. */
  77. @SuppressWarnings("unchecked")
  78. public List<Infovoteitm> selectByExample(InfovoteitmExample example) throws SQLException {
  79. List<Infovoteitm> list = sqlMapClient.queryForList("InfoVoteItm.ibatorgenerated_selectByExample", example);
  80. return list;
  81. }
  82.  
  83. /**
  84. * This method was generated by Apache iBATIS ibator.
  85. * This method corresponds to the database table InfoVoteItm
  86. *
  87. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  88. */
  89. public int updateByExampleSelective(Infovoteitm record, InfovoteitmExample example) throws SQLException {
  90. UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
  91. int rows = sqlMapClient.update("InfoVoteItm.ibatorgenerated_updateByExampleSelective", parms);
  92. return rows;
  93. }
  94.  
  95. /**
  96. * This method was generated by Apache iBATIS ibator.
  97. * This method corresponds to the database table InfoVoteItm
  98. *
  99. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  100. */
  101. public int updateByExample(Infovoteitm record, InfovoteitmExample example) throws SQLException {
  102. UpdateByExampleParms parms = new UpdateByExampleParms(record, example);
  103. int rows = sqlMapClient.update("InfoVoteItm.ibatorgenerated_updateByExample", parms);
  104. return rows;
  105. }
  106.  
  107. /**
  108. * This class was generated by Apache iBATIS ibator.
  109. * This class corresponds to the database table InfoVoteItm
  110. *
  111. * @ibatorgenerated Wed Mar 09 16:57:25 CST 2011
  112. */
  113. private static class UpdateByExampleParms extends InfovoteitmExample {
  114. private Object record;
  115.  
  116. public UpdateByExampleParms(Object record, InfovoteitmExample example) {
  117. super(example);
  118. this.record = record;
  119. }
  120.  
  121. public Object getRecord() {
  122. return record;
  123. }
  124. }
  125. }

iBATIS代码生成分析的更多相关文章

  1. MyBatis源码分析(一)

    MyBatis故事: 官方网站:http://www.mybatis.org 官方文档:http://www.mybatis.org/mybatis-3/ GitHub:https://github. ...

  2. 使用代码生成工具快速生成基于ABP框架的Vue+Element的前端界面

    世界上唯一不变的东西就是变化,我们通过总结变化的规律,以规律来应付变化,一切事情处理起来事半功倍.我们在开发后端服务代码,前端界面代码的时候,界面都是依照一定的规律进行变化的,我们通过抽取数据库信息, ...

  3. Thrift之TProtocol系列TBinaryProtocol解析

    首先看一下Thrift的整体架构,如下图: 如图所示,黄色部分是用户实现的业务逻辑,褐色部分是根据thrift定义的服务接口描述文件生成的客户端和服务器端代码框架(前篇2中已分析了thrift ser ...

  4. 框架学习:ibatis框架的结构和分析

    由于最近一段时间比较忙碌,<框架学习>系列的文章一直在搁浅着,最近开始继续这个系列的文章更新. 在上篇文章中我们说到了hibernate框架,它是一种基于JDBC的主流持久化框架,是一个优 ...

  5. 【异常及源码分析】org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.type.TypeException: Could not set parameters for mapping: ParameterMapping

    一.异常出现的场景 1)异常出现的SQL @Select("SELECT\n" + " id,discount_type ,min_charge, ${cardFee} ...

  6. [源码分析]从"UDF不应有状态" 切入来剖析Flink SQL代码生成 (修订版)

    [源码分析]从"UDF不应有状态" 切入来剖析Flink SQL代码生成 (修订版) 目录 [源码分析]从"UDF不应有状态" 切入来剖析Flink SQL代码 ...

  7. mybatis-plus报org.apache.ibatis.binding.BindingException分析【转载】

    这个问题整整纠结了我四个多小时,心好累啊...不废话... 背景:Spring整合Mybatis 报错:org.apache.ibatis.binding.BindingException: Inva ...

  8. mybatis源码分析(4)----org.apache.ibatis.binding包

    1.  我们通过接口操作数据库时,发现相关的操作都是在org.apache.ibatis.binding下 从sqSessin 获取getMapper() SqlSession session = s ...

  9. HotSpot模板解释器目标代码生成过程源码分析

    虽然说解释执行模式是逐字逐句翻译给目标平台运行的,但这样的过程未免太过缓慢,如果能把字节码说的话做成纸条,运行时只要把对应的纸条交给目标平台就可以了,这样,执行速度就会明显提升.JVM的Hotspot ...

随机推荐

  1. [整理]Centos6.5 + hadoop2.6.4环境搭建

    搭建Hadoop集群环境(3台机器) 1 准备环境 1.1 安装系统,并配置网络使3台机器互联互通,且SSH可直连(无需密码.保存私钥) 1.1.1 安装系统 安装Centos 6.5系统 安装过程略 ...

  2. Adressing

  3. PARENT VIEW INVALIDATE

    如果启动display list,parentview 调用invalidate,子view是不会是去调用onDraw的,因为直接调用displaylist了,如果parentview认为子view应 ...

  4. SQL 2008 R2下载 升级R2 SP1或者SQL 2008从10.50.1600升级10.5.2500

    SQL Server 2008 R2 中英文 开发版/企业版/标准版 链接地址 一. 简体中文 1. SQL Server 2008 R2 Developer (x86, x64, ia64) - D ...

  5. Database cannot be started in this edition of SQL Server" error when restoring a Microsoft Dynamics CRM database

    处理办法:http://support.microsoft.com/kb/2567984

  6. 电脑安装Android4.0虚拟机的做法

    在开始教程之前,先给大家展示一下成功运行Android 4.0虚拟机的界面,经过笔者测试,体验很流畅,喜欢DIY和对开发感兴趣的朋友们可以猛击下一页,继续浏览教程. 准备工作 在体验前我们首先要下载J ...

  7. exp_tools

    #pwntools # github https://github.com/Gallopsled/pwntools 在线帮助文档 https://docs.pwntools.com/en/stable ...

  8. AC6102 DDR2测试工程

    AC6102 DDR2测试工程 本文档介绍AC6102上DDR2存储器基于Verilog代码的测试过程.AC6102上使用了2片16bit的DDR2存储器组成了32bit的硬件总线.虽然是32bit硬 ...

  9. javascript - 可编辑表格控件 支持全键盘操作(无JS框架)

    项目中经常会用到表格编辑控件,网上也有不少,但是确实没有完全符合我要求的, 自己写一个吧! 1.该控件支持 数据显示列,文本编辑列,选择列,下拉列,索引列,删除列 六种列类型 2.支持全键盘操作,自定 ...

  10. sql server常用语法点

    if exists(select name from sysobjects where name = 'stuInfo')drop table stuInfogocreate table stuInf ...