2

I'm new to working with Micronaut Recently got a new job at a company who use it.

@JdbcRepository()
public interface UserDataRepository extends CrudRepository<UserRecord, UUID> {

    ...

    @Query(value = "SELECT * FROM Users u " +
            "INNER JOIN LabUsers lu ON u.Id = lu.UserID " +
            "WHERE :labID = lu.LabID")
    List<UserRecord> findByLabID(final String labID);

}

Every time I try to execute this method by running an integration test, I am getting the following exception:

io.micronaut.http.client.exceptions.HttpClientResponseException: Internal Server Error: Unable to set PreparedStatement value: The index 1 is out of range.

Really struggling to figure this out. Have described it to a colleague who is also out of ideas for things to try.

Elsewhere in this project, there is some pre-existing code which does something very similar. It works fine.

Thanks in advance.

Chris
  • 839
  • 2
  • 10
  • 33
  • I know nothing about micronaut, but it looks like spring data Jpa, where I would expect a @Param on the method parameter labID. – Nathan Hughes Feb 09 '21 at 15:22
  • Thanks for the idea. I know what you mean, I usually use Spring myself, but this doesn't apply to Micronaut. – Chris Feb 10 '21 at 10:53

1 Answers1

1

Fixed the problem. The solution was to change the version of micronaut-data to 2.0.0. Previously, it was version 2.2.0.

I mentioned that this code working elsewhere in the project - this was a mistake, it was working elsewhere in a different project, and that project was using version 2.0.0.

Chris
  • 839
  • 2
  • 10
  • 33
  • Is there anything that has changed with micronaut-data 2.2.0 which is creating this problem? – AmitB10 Feb 18 '21 at 05:14
  • Not that I could see. I have looked through the release notes and there appears to be nothing relevant changed. But changing the version did fix it without any code changes needed. – Chris Feb 18 '21 at 15:12