1.實體map.xml中配置:
主鍵獲取方式配置,mysql
<selectKey resultClass="java.lang.Integer" keyProperty="id">
select LAST_INSERT_ID()
</selectKey>
動態拼接where條件
<dynamic prepend="where">
<isNotNull>
plateId=#value#
</isNotNull>
</dynamic>
2.config配置
typeAlias 定義類型別名
<typeAlias alias="Item" type="com.tudou.tudoupromotion.entity.Item"/>
typeHandler 自定義類型轉換
比如,將數據庫中的1,2,3格式的數據轉換為java 枚舉
<typeHandler
javaType="com.tudou.tudoupromotion.entity.Plate"
callback="com.tudou.tudoupromotion.ext.ibatis.PlateHandler"/>
線程緩存等配置
<settings
cacheModelsEnabled="true"
enhancementEnabled="true"
lazyLoadingEnabled="false"
maxRequests="32"
maxSessions="10"
maxTransactions="5"
useStatementNamespaces="true"
/>
cacheModelsEnabled="true" 是否啟動緩存機制
enhancementEnabled="true" 是否針對POJO啟動字節碼增強機制以提升getter/setter的調用效能避免使用javaReflect所帶來的性能開銷。同時Lazy Loading帶來極大的性能提升。
maxRequests最大并發請求數(Statement數)
maxTransactions最大并發事務數
maxSessions最大Session數,即當前最大允許的并發SqlMapCliect數maxSessions設定必須界于
maxTransactions和maxRequests之間.即
maxTransactions>maxSessions>maxRequests