ibatis2到mybatis的转变Word格式文档下载.docx

上传人:b****3 文档编号:17825071 上传时间:2022-12-11 格式:DOCX 页数:11 大小:20.54KB
下载 相关 举报
ibatis2到mybatis的转变Word格式文档下载.docx_第1页
第1页 / 共11页
ibatis2到mybatis的转变Word格式文档下载.docx_第2页
第2页 / 共11页
ibatis2到mybatis的转变Word格式文档下载.docx_第3页
第3页 / 共11页
ibatis2到mybatis的转变Word格式文档下载.docx_第4页
第4页 / 共11页
ibatis2到mybatis的转变Word格式文档下载.docx_第5页
第5页 / 共11页
点击查看更多>>
下载资源
资源描述

ibatis2到mybatis的转变Word格式文档下载.docx

《ibatis2到mybatis的转变Word格式文档下载.docx》由会员分享,可在线阅读,更多相关《ibatis2到mybatis的转变Word格式文档下载.docx(11页珍藏版)》请在冰豆网上搜索。

ibatis2到mybatis的转变Word格式文档下载.docx

 

<

settingname="

x"

value="

foo"

/settings>

and

settingsuseStatementNamespaces="

true"

canberemoved,sincetheuseofnamespaceshasbecomemandatory.

typeAlias>

mustbemovedoutofthe<

sqlMap>

elementto<

typeAliases>

/typeAliases>

/configuration>

... 

typeAlias.../>

transactionManager>

and<

dataSource>

transactionManagertype="

JDBC"

commitRequired="

false"

dataSourcetype="

your.package.CustomDataSourceFactory"

/>

/transactionManager>

environmentsdefault="

env"

environmentid="

propertyname="

commitRequired"

/environment>

/environments>

sqlMapresource=.../>

mappers>

mapperresource=.../>

/mappers>

Mapping

∙Therootelement<

mapper>

∙TheattributeparameterClassshouldbechangedtoparameterType

∙TheattributeresultClassshouldbechangedtoresultType

∙Theattributeclassshouldbechangedtotype

∙thecolumnIndexattributedoesnotexistanymoreforthe<

result>

tag

∙ThegroupByattributehasbeeneliminated.HereisanexampleofgroupByfroma2.xsqlMap:

resultMapid="

productRM"

class="

product"

groupBy="

id"

resultproperty="

column="

product_id"

name"

product_name"

category"

product_category"

subProducts"

resultMap="

Products.subProductsRM"

/resultMap>

New:

type="

>

idproperty="

product"

name"

product_name"

category"

product_category"

collectionproperty="

NestedresultMaps

Theseshouldnowbespecifiedusingthe<

association>

tag.

resultMap...>

client"

Client.clientRM"

associationproperty="

parameterMap>

Althoughthistagisdeprecated,itcanbeusedasiniBatis2.Howeverforversionsupto3.0.3thereisabugwhenusingtype="

map"

andnotspecifyingjavaTypeforaparameter.Thiswillresultin

Thereisnogetterforpropertynamed'

...'

in'

interfacejava.util.Map'

ThisshouldbesolvedinMyBatis3.0.4.Forversions3.0.3andearliertheworkaroundistoexplicitlyspecifyjavaType.

Inlineparameters

#value#

#{value}

jdbcTypechanges

jdbcType="

ORACLECURSOR"

CURSOR"

NUMBER"

NUMERIC"

Storedprocedures

∙the<

procedure>

tagdoesn'

texistanymore.Use<

select>

<

insert>

or<

update>

.

procedureid="

getValues"

parameterMap="

getValuesPM"

{?

=callpkgExample.getValues(p_id=>

?

)} 

/procedure>

selectid="

statementType="

CALLABLE"

)} 

/select>

Ifyou'

recallinganinsertprocedurethatreturnsavalue,youcanuse<

insteadof<

butmakesuretospecifyuseCache="

andflushCache="

.You'

llalsohavetoforceacommit.

∙forstoredproceduresthatreturnacursor,thereisabug(see 

issue30 

)whenusingnestedresultmaps(i.e.theoutputparameter'

sresultMapcontainsan<

tagwiththeresultMapattribute).Aslongastheissueisnotfixed,youhavetospecifytheresultMapoftheoutputparameteronthestatementitselfaswell,orthenestedresultMapwillnotbepopulated.

Caching

cacheModelid="

myCache"

LRU"

flushIntervalhours="

24"

size"

100"

/cacheModel>

cacheflushInterval="

86400000"

eviction="

Note:

youcanomiteviction="

sinceitisthedefault.

flushOnExecute>

tagisreplacedbytheflushCacheattributeforthestatementsandthecachewillbeusedbyallselectstatementsbydefault.

DynamicSQL

ThemostcommondynamicSQLinmyprojectisisNotNull.Hereisanexamplereplacementregex:

Pattern:

isNotNull.*?

property=\"

(.*?

)\"

/isNotNull>

Replacement:

iftest="

$1!

=null"

/if>

配置文件示例

SqlMapConfig

?

xmlversion="

1.0"

encoding="

UTF-8"

"

cacheEnabled"

lazyLoadingEnabled"

aggressiveLazyLoading"

typeAliasalias="

SyckSmsInfoBean"

type="

com.wtyt.callcenter.order.initOrder.bean.SyckSmsInfoBean"

SyckSmsCarBean"

com.wtyt.callcenter.order.initOrder.bean.SyckSmsCarBean"

GoodsSourceBean"

com.wtyt.callcenter.goods.bean.GoodsSourceBean"

WorkRecordInfoBean"

com.wtyt.callcenter.order.bean.WorkRecordInfoBean"

DriverBean"

com.wtyt.callcenter.ivrRegister.bean.DriverBean"

LogLocateAuthorisedBean"

com.wtyt.callcenter.ivrRegister.bean.LogLocateAuthorisedBean"

OrgDriverRelBean"

com.wtyt.callcenter.ivrRegister.bean.OrgDriverRelBean"

OrgnizationBean"

com.wtyt.callcenter.ivrRegister.bean.OrgnizationBean"

callcenter_cim"

POOLED"

driver"

oracle.jdbc.OracleDriver"

url"

jdbc:

oracle:

thin:

@192.168.1.248:

1521:

TSH1"

username"

cim3"

password"

oracle"

/dataSource>

mapperresource="

com/wtyt/callcenter/order/order-sql-map.xml"

com/wtyt/callcenter/ivrRegister/register-driver-sql.xml"

Mapper

-//mybatis.org//DTDMapper"

mappernamespace="

com.wtyt.callcenter.order.initOrder.InitCallcenterFromCimDao"

goodsBeanMap"

<

orgName"

ORG_NAME"

javaType="

string"

orgId"

ORG_ID"

int"

contectPeople"

CONTACT_PERSON"

javaType="

contectPhone"

TEL_NO"

contectMobileNo"

MOBILE_NO"

userId"

USER_ID"

userType"

USER_TYPE"

loginName"

LOGIN_NAME"

area"

AREA"

mainArea"

MAIN_AREA"

SyckSmsInfoMap"

agentId"

AGENT_ID"

goodsName"

GOODS_TYPE"

carModel"

SMS_CART_TYPE"

length"

SMS_CART_LENGTH"

weight"

SMS_CART_TONNAGE"

width"

SMS_CART_VOLUME"

loadGoodsAddress"

START_CITY_AREA"

dischargeGoodsAddress"

END_CITY_AREA"

smsNote"

CONTENT"

goodsBean"

SYCK_SMS_LIST_ID"

resultMap="

cartBeanList"

java.util.ArrayList"

ofType="

cartBeanMap"

phone"

DRIVER_MOBILE_NO"

freightState"

FREIGHT_STATE"

curPosition"

CUR_POSOTION"

driverName"

REALNAME"

idCard"

ID_CARD"

address"

ADDRESS"

ownerName"

OWNER_NAME"

ownerPhone"

MOBILE_NO_2"

license"

CART_BADGE_NO"

cartModel"

CART_TYPE"

cartLength"

CART_LENGTH"

cartWidth"

CART_WIDTH"

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 冶金矿山地质

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1