3

I use postgreSQL. Here is my request in a 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>

Here is my error:

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

What is a reason and how to solve it?

Maksym Rybalkin
  • 453
  • 1
  • 8
  • 22

3 Answers3

5

I meet the same error when use mysql. But I solved it by adding NoArgsConstructor and AllArgsConstructor both. I use @Builder of lombok but missed constructor annotation. The error log shows too little message to find it.

Tranfer Will
  • 118
  • 1
  • 5
1

You can fix by add constructor with no argument, alongside constructor with arguments

    //Add Constructor with no arguments to fix this error
    public UserAdmin() {
    }
    //Along side the constructor with arguments
    public UserAdmin(String username, String password, String email, Date date_created, Date date_expired) {
        this.username = username;
        this.password = password;
        this.email = email;
        this.date_created = date_created;
        this.date_expired = date_expired;
    }

0

I solved the problem. Just need to add allArgs constructor to my entity

Maksym Rybalkin
  • 453
  • 1
  • 8
  • 22