当参数很长时,Mybatis IF TEST要求getter

时间:2018-01-15 14:09:40

标签: java spring mybatis spring-mybatis

我正在运行一个带有spring + mybatis的应用程序,我有以下mapper方法:

List<Lot> selectAvailableForAuction(Long auctionId);

XML方法如下:

<select id="selectAvailableForAuction" resultMap="BaseResultMap" parameterType="Long">
        SELECT <include refid="Base_Column_List" />
        FROM lot
        WHERE
            id NOT IN (
                SELECT lot_id
                FROM auction_lots
                <if test="auctionId != null">
                    WHERE auction_id != #{auctionId}
                </if>
        )
</select>

如您所见,参数是Long,当我测试auctionId以检查该值是否为null时,它会返回以下错误:

Caused by: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'auctionId' in 'class java.lang.Long'
    at org.apache.ibatis.reflection.Reflector.getGetInvoker(Reflector.java:419)
...

但是,如果我删除它将完美地捕获auctionId。看起来测试在接收的参数中查找属性。我正在寻找它,但我没有找到如何测试mybatis函数本身的参数。

有什么想法吗?

0 个答案:

没有答案