IBATIS3 Mapper Configuration File instance

Source: Internet
Author: User
Tags constructor garbage collection

<?xml version= "1.0" encoding= "UTF-8"?>
<! DOCTYPE Mapper Public "-//IBATIS.APACHE.ORG//DTD Mapper 3.0//
EN "HTTP://IBATIS.APACHE.ORG/DTD/IBATIS-3-MAPPER.DTD" >

<mapper>

<select id= "" parametermap= "" parametertype= "" resultmap= ""
Resulttype= "" usecache= "true" flushcache= "true" timeout= "" fetchsize= ""
Statementtype= "STATEMENT" resultsettype= "Forward_only" >
<!--
StatementType can be set to Statement,prepared,callable,
The default is prepared, as you can use the callable type when you call a stored procedure
ResultsetType result set type, mainly said cursor, has directionality, can go to
Forward_only, scroll_sensitive, scroll_insensitive default based on database driver
-

</select>

 <insert id= "" usegeneratedkeys= "true" keyproperty= "" ></INSERT>
 <!--
   usegeneratekeys whether to use a database auto-generated key (such as a self-increment column) by default false
  keyproperty assigns the database auto-generated key value to which field value
 -->

 <!--Ibatis also provides a primary key value generation scheme for databases that do not support automatic generation of primary key values, such as a random number primary key value:-->
 <insert id= "Insertauthor" Parametertype= "Domain.blog.Author";
  <selectkey keyproperty= "id" resulttype= "int" order= " Before,
   select
   cast (RANDOM () *1000000 as INTEGER) a from SYSIBM. SYSDUMMY1
  </selectkey>
  <!--
   order can be set to before, after. If it is before, the Select key value is first assigned, and then the INSERT statement is executed.
    If after, the INSERT statement is executed before select. Default after
  -->
  insert to Author
   (ID, username, password, email,bio,
  favourite_section)
  values
   (#{id}, #{username}, #{password}, #{email},
  #{bio},
  #{favouritesection,jdbctype=varchar}
  <!--
    Define special parameter types #{ Property,javatype=int,jdbctype=numeric}
  -->
  )
 </insert>

<!--SQL definition reuse SQL code--
<sql id= "Usercolumns" >
Id,username,password
</sql>
<select id= "selectusers" parametertype= "int" resulttype= "HashMap" >
Select
<include refid= "Usercolumns"/>
From some_table
WHERE id = #{id}
</select>

<resultmap type= "" Id= "" >

<!--The constructor property allows you to configure some parameters to inject properties through the class constructor--
<constructor>
<idarg column= "" javatype= "" jdbctype= "" typehandler= ""/>
<arg column= "" javatype= "" jdbctype= "" typehandler= ""/>
</constructor>

<!--
Id,result maps the values of a single column to a single simple type attribute in Pojo (such as int,double,date, and so on)
ID mapping primary key, result mapping normal property
-
<id column= "" javatype= "" jdbctype= "" property= "" typehandler= ""/>
<result column= "" javatype= "" jdbctype= "" property= ""
Typehandler= ""/>

<!--association tags define associations between entities--
<association property= "" >
<id/>
<result/>
<association property= "" ></association>
<collection property= "" ></collection>
<discriminator javatype= "" >
<case value= "" ></case>
</discriminator>
</association>

<!--collection similar to association corresponding to the collection properties in Pojo, such as List Map--
<collection property= "" Oftype= "" ></collection>

<!--
Sometimes the values we get from the database not only correspond to a pojo, but may vary according to the parameters of the Pojo that do not understand,
If the properties of a vehicle are different depending on the truck or car, the following configurations can be used
-
<discriminator javatype= "int" column= "Vehicle_type" >
<case value= "1" resultmap= "Carresult"/>
<case value= "2" resultmap= "Truckresult"/>
<case value= "3" resultmap= "Vanresult"/>
<case value= "4" resultmap= "Suvresult"/>
</discriminator>
</resultMap>

<!--
Cache: Configure the caching mechanism within a namespace Cache-ref: Reference cache configuration for 21 namespaces
Cache Expiration algorithm:
LRU Least Recently used
FIFO Advanced First Out
SOFT only if there is currently insufficient memory, the JVM will reclaim its included references when it is garbage collected
WEAK as long as the JVM starts the garbage collection mechanism, the WeakReference object will be recycled by the JVM
-
<cache eviction= "" flushinterval= "" readonly= "" size= "" type= "" ></cache>
<cache-ref namespace= ""/>

</mapper>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.