3.7K Star 11.7K Fork 4.6K

卓源软件 / JeeSite 4.2

 / 详情

是否支持databaseId

Done
Opened this issue  
2021-04-26 17:37

该问题是怎么引起的?

如果同时使用多种数据源,mapper中无法使用databaseId

重现步骤

<select id="findListByLic"  parameterType="PmProjLicModule" resultType="PmProjLicModule" databaseId="mysql">
        SELECT *
        FROM ${sqlMap.table.toSql()}
        <where>
            ${sqlMap.where.toSql()}   and length(#{licId.id})>0
        </where>
        ORDER BY ${sqlMap.order.toSql()}
    </select>

    <select id="findListByLic"  parameterType="PmProjLicModule" resultType="PmProjLicModule" databaseId="sqlserver">
        SELECT *
        FROM ${sqlMap.table.toSql()}
        <where>
            ${sqlMap.where.toSql()}   and len(#{licId.id})>0
        </where>
        ORDER BY ${sqlMap.order.toSql()}
    </select>

报错信息



Comments (2)

秦秋随 created任务
秦秋随 set related repository to 卓源软件/JeeSite 4.2
展开全部操作日志

不用写databaseId。不同的语句,使用if判断就行,这样写:(请 star 下本项目,谢谢)

    <!-- 判断数据库类型例子 -->
    <select id="findListByLic"  parameterType="PmProjLicModule">
        SELECT *
        FROM ${sqlMap.table.toSql()}
        <where>
            ${sqlMap.where.toSql()}
            <if test="global.dbName == 'mysql'">and length(#{licId.id})>0</if>
            <if test="global.dbName == 'oracle'">and len(#{licId.id})>0</if>
        </where>
        ORDER BY ${sqlMap.order.toSql()}
    </select>
秦秋随 changed issue state from 待办的 to 已完成

Sign in to comment

状态
Assignees
Milestones
Pull Requests
关联的 Pull Requests 被合并后可能会关闭此 issue
Branches
Planed to start   -   Planed to end
-
Top level
Priority
参与者(2)
6732 thinkgem 1578914432
Java
1
https://gitee.com/thinkgem/jeesite4.git
git@gitee.com:thinkgem/jeesite4.git
thinkgem
jeesite4
JeeSite 4.2

Search