I have problems with the following @Query, to which I can not find error reason: SQLGrammarException
@Query("select distinct e.issue.company from CreditLinesAmendmentEntity
e where " + "(e.issue.ownerBank!=null and (e.issue.ownerBank = ?1)) and " +
"(UPPER(e.issue.company.name) like ?2 OR UPPER(e.issue.company.companyid) like ?2) AND " +
"e.issue.status IN ?3 and " +
"(e.creationDate!=null and ( e.creationDate >= ?4 and e.creationDate <= ?5 )) AND " +
"(e.transactionVersion = (SELECT MAX(ee.transactionVersion) FROM
CreditLinesAmendmentEntity ee WHERE ee.transactionId=e.transactionId))")
Page<Company>
findBeneficiariesByBeneficiaryBankAndStatusAndCreationDate(Bank beneficiaryBank,
String search, List<Status> statuses, Date earliestDate, Date now, Pageable
page);