Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Spring Mybatis-如何动态启动查询_Spring_Mybatis_Ibatis - Fatal编程技术网

Spring Mybatis-如何动态启动查询

Spring Mybatis-如何动态启动查询,spring,mybatis,ibatis,Spring,Mybatis,Ibatis,我正在寻找mybatis标签,在这里我可以动态地启动整个查询。我想在代码中构造完整的查询作为参数,并从mybatis中激发它。有什么方法可以做到这一点吗?也许下面的示例可以为您提供一种不同的想法—Mybatis支持的动态查询: <select id="runQuery" resultType="map" parameterType="map" databaseId="mysql"> SELECT <if test="disableDisti

我正在寻找mybatis标签,在这里我可以动态地启动整个查询。我想在代码中构造完整的查询作为参数,并从mybatis中激发它。有什么方法可以做到这一点吗?

也许下面的示例可以为您提供一种不同的想法—Mybatis支持的动态查询:

   <select id="runQuery" resultType="map" parameterType="map" databaseId="mysql">
        SELECT
        <if test="disableDistinct == false">
        DISTINCT
        </if>
        ${columnList}
        FROM ${fromClause}
        <if test="whereClause != null">
        WHERE ${whereClause}
        </if>
        <if test="orderClause != null">
        ORDER BY ${orderClause}
        </if>
        <if test="totalRows != null">
        LIMIT ${totalRows}
        </if>
    </select>

与其在代码中构造查询,不如在mybatis中使用动态SQL来传递所需的条件参数。Mybatis非常支持在SQL查询中评估条件。