Mybatis-3: can mapper namespace support alias锛宭ike typeAlias type

Created on 18 Dec 2017  路  2Comments  路  Source: mybatis/mybatis-3

see title

waiting for feedback

Most helpful comment

Hello @kazuki43zoo. I know you closed this two years ago, but I think it is still an interesting question. The use case would be able to reduce verbosity in mapper files.

In particular we would be to be able to make shorter include statements so that

<include refid="com.mycompany.mypackage.mysubpackage.mysubsubpackage.MyMapper.mySQLStatement">

could be shortened to

<include refid="myAlias.MyMapper.mySQLStatement">

and similarly for referencing resultTypes and resultMaps in select statements so that one could write

<select id="myId" resultType="com.mycompany.mypackage.mysubpackage.mysubsubpackage.MyType">

as

<select id="myId" resultType="myAlias.MyType">

Perhaps this could be achieved with a statement at the beginnning of the mapper XML file of the form:

<namespace-alias refid="com.mycompany.mypackage.mysubpackage.mysubsubpackage" alias="myAlias"/>

All 2 comments

Could you provide a use-case for this request?

Hello @kazuki43zoo. I know you closed this two years ago, but I think it is still an interesting question. The use case would be able to reduce verbosity in mapper files.

In particular we would be to be able to make shorter include statements so that

<include refid="com.mycompany.mypackage.mysubpackage.mysubsubpackage.MyMapper.mySQLStatement">

could be shortened to

<include refid="myAlias.MyMapper.mySQLStatement">

and similarly for referencing resultTypes and resultMaps in select statements so that one could write

<select id="myId" resultType="com.mycompany.mypackage.mysubpackage.mysubsubpackage.MyType">

as

<select id="myId" resultType="myAlias.MyType">

Perhaps this could be achieved with a statement at the beginnning of the mapper XML file of the form:

<namespace-alias refid="com.mycompany.mypackage.mysubpackage.mysubsubpackage" alias="myAlias"/>
Was this page helpful?
0 / 5 - 0 ratings