如何解决MyBatis selectForUpdate中的indexOutOfBounds错误?

Мак*_*кин 4 java mybatis spring-mybatis mybatis-sql mybatis-mapper

我使用postgreSQL。这是我在 myBatisMapper 中的请求:

<select id="findByStatusAndIdentityAndPrvCode" parameterType="java.lang.String" resultMap="Request">
        select
        from req_tab
        where status in ('I', 'D', 'Q')
          and identity = #{identity}
          and prv_code = #{prvCode}
        limit 1 for update
    </select>
Run Code Online (Sandbox Code Playgroud)

这是我的错误:

org.apache.ibatis.exceptions.PersistenceException: 
Error querying database.  Cause: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
The error may exist in ru/infogate/dao/mapper/ReqMapper.xml
The error may involve ru.infogate.dao.mapper.ReqMapper.findByStatusAndIdentityAndPrvCode
The error occurred while handling results
SQL: select         from req_tab         where status in ('I', 'D', 'Q')           and identity = ?           and prv_code = ?         limit 1 for update
Cause: java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
Run Code Online (Sandbox Code Playgroud)

这是什么原因以及如何解决呢?

小智 8

我在使用mysql的时候也遇到同样的错误。但我通过添加 NoArgsConstructor 和 AllArgsConstructor 解决了这个问题。我使用 lombok 的 @Builder 但缺少构造函数注释。错误日志显示的消息太少,无法找到它。