I have an entity, and the DAO with interface JpaRepository<MyEntity, Long>
. Using EclipseLink.
I'm using the following method from the DAO:
Iterable<MyEntity> findAll(Iterable<Long> ids);
in this way:
List<Long> listOfIds = Arrays.asList(new Long[] {1,2,3});
Iterable<MyEntity> entities = dao.findAll(listOfIds);
I've got the MySQL exception:
java.sql.SQLException: Operand should contain 1 column(s)
The SQL query that is executed in the database has the following syntax:
SELECT id, creation_date, column1, column2 FROM my_entity WHERE (id IN ((1,2,3)))
The problem is in the last braces - there are too many of them. The working query is:
SELECT id, creation_date, column1, column2 FROM my_entity WHERE (id IN (1,2,3))
Any reason why the Spring Data adds these unnecessary braces? Any way to fix it?