Why do the following two simple integration tests fail, using Spring 1.5.4.RELEASE and Eclipselink 2.6.4?
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {MyApp.class})
@WebAppConfiguration
@DirtiesContext(classMode = ClassMode.BEFORE_CLASS)
public class DbDummyIT {
@Autowired
private DbDummyRepository repo;
@Test
public void findAllFails() {
List<String> keys = Arrays.asList("1", "2");
List<DbDummy> result = repo.findAll(keys);
assertThat(result.isEmpty()).isTrue();
}
@Test
public void findByKeyInFails() {
List<String> keys = Arrays.asList("1", "2");
List<DbDummy> result = repo.findByKeyIn(keys);
assertThat(result.isEmpty()).isTrue();
}
}
Based on:
@Entity
@UuidGenerator(name = DbDummy.KEY_GENERATOR)
public class DbDummy {
public static final String KEY_GENERATOR = "KeyGenerator";
@Id
@Column(name = ColumnName.KEY, nullable = false)
@GeneratedValue(generator = KEY_GENERATOR)
public String key;
}
@Repository
public interface DbDummyRepository extends JpaRepository<DbDummy, String> {
List<DbDummy> findByKeyIn(List<String> keys);
}
Both tests fail with a JpaSystemException when calling the find
queries. The error message is:
Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.6.4.v20160829-44060b6): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLSyntaxErrorException: unexpected token: ) in statement [SELECT Key FROM DBDUMMY WHERE (Key IN ((?,?)))]
Error Code: -5581
Call: SELECT Key FROM DBDUMMY WHERE (Key IN ((?,?)))
bind => [2 parameters bound]
Query: ReadAllQuery(referenceClass=DbDummy sql="SELECT Key FROM DBDUMMY WHERE (Key IN (?))")
The statement looks indeed wrong to me. Doesn't Key IN ((?, ?))
query for a list of bi-valued tuples? Shouldn't a list of strings should be queried as Key IN (?, ?)
?
Looks like a long-living bug in Eclipselink: https://bugs.eclipse.org/bugs/show_bug.cgi?id=349477