# JpaRepository findAll giving "Parameter index out of range" after update to Hibernate 6

**URL:** https://discourse.hibernate.org/t/jparepository-findall-giving-parameter-index-out-of-range-after-update-to-hibernate-6/9265
**Category:** Hibernate ORM
**Created:** [March 26, 2024, 11:32pm UTC](https://discourse.hibernate.org/t/jparepository-findall-giving-parameter-index-out-of-range-after-update-to-hibernate-6/9265 "2024-03-26T23:32:18Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![IVR\_Avenger](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/ivr_avenger/32/3091_2.png) [@IVR\_Avenger](https://discourse.hibernate.org/u/IVR_Avenger)
#### Post date: [March 26, 2024, 11:32pm UTC](https://discourse.hibernate.org/t/jparepository-findall-giving-parameter-index-out-of-range-after-update-to-hibernate-6/9265/1 "2024-03-26T23:32:18Z")

</div>

Updating from Hibernate 5 to 6, I notice that attempting a `JpaRepository.findAll` for a particular entity is now yielding this exception:

```auto
2024-03-26T19:23:00,066-0400 DEBUG () [http-nio-9010-exec-8] o.h.e.j.s.SqlExceptionHelper - JDBC exception executing SQL [select am1_0.id,am1_0.application_id,am1_0.created_by,am1_0.created_date,am1_0.extended_data_id,am1_0.last_modified_by,am1_0.last_modified_date,am1_0.name,am1_0.uuid,am1_0.version from access_management am1_0 join applications a1_0 on a1_0.id=am1_0.application_id join clients c1_0 on c1_0.id=a1_0.client_id where c1_0.client_name=? and c1_0.uuid=? and c1_0.id=? and a1_0.uuid=? and a1_0.id=? and a1_0.application_name like ? escape '\' limit ?,?] [n/a]
java.sql.SQLException: Parameter index out of range (7 > number of parameters, which is 6).

```

Of note, the entity is different from others in my app in that it has this attribute:

```auto
	@ManyToMany(cascade = CascadeType.PERSIST, fetch = FetchType.EAGER)
	@JoinTable(
			name = "access_management_role_mapping",
			joinColumns = @JoinColumn(name = "access_management_id"),
			inverseJoinColumns = @JoinColumn(name = "roles_id"))
	@CsvBindByName(column = "roles")
	private List<Role> roles = new ArrayList<>();

```

I have ensured:

1. A MariaDB Dialect correct for my target DB is selected.
2. My Hibernate 5 application version, with unchanged Entity classes, is able to read this data.

I suspect that generated SQL / HQL is majorly wrong, as I’ve never seen anything like this before: `escape '\'`, but I’m not sure how to approach troubleshooting this.

Any introductory suggestions? Thank you!

---

<div class="post-metadata">

### Author: ![beikov](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/beikov/32/258_2.png) [@beikov](https://discourse.hibernate.org/u/beikov)
#### Post date: [March 27, 2024, 12:55pm UTC](https://discourse.hibernate.org/t/jparepository-findall-giving-parameter-index-out-of-range-after-update-to-hibernate-6/9265/2 "2024-03-27T12:55:01Z")

</div>

The exception clearly states that something tries to bind a parameter at index 7 though there are only 6 parameters. How come you conclude that this has something to do with the `escape` syntax?  
Either way, please try to create a reproducer with our [test case template](https://github.com/hibernate/hibernate-test-case-templates/blob/master/orm/hibernate-orm-6/src/test/java/org/hibernate/bugs/JPAUnitTestCase.java) and if you are able to reproduce the issue, create a bug ticket in our [issue tracker](https://hibernate.atlassian.net) and attach that reproducer.

---

<div class="post-metadata">

### Author: ![IVR\_Avenger](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.hibernate.org/ivr_avenger/32/3091_2.png) [@IVR\_Avenger](https://discourse.hibernate.org/u/IVR_Avenger)
#### Post date: [April 2, 2024, 12:30am UTC](https://discourse.hibernate.org/t/jparepository-findall-giving-parameter-index-out-of-range-after-update-to-hibernate-6/9265/3 "2024-04-02T00:30:14Z")

</div>

Figured it out - the JpaRepository and Entity were fine. Instead, I was using a SearchExample object unknowingly, and it was malformed. Correcting that object or searching without it solved my issue.
