Метод хранилища JPA с нативным запросом, содержащим '&&' работает с Long [], но не Collection JAVA

Программисты JAVA общаются здесь
Anonymous
Метод хранилища JPA с нативным запросом, содержащим '&&' работает с Long [], но не Collection

Сообщение Anonymous »

В одном из моих репозиториев JPA Data Spring у меня есть этот собственный запрос (PostgreSQL): < /p>

Код: Выделить всё

@Query(value = "SELECT * FROM ballots b WHERE b.companies && :companyIds and b.meeting_id in :meetingIds", nativeQuery = true)
List findByIds(Long[] companyIds, Long[] meetingIds);
< /code>
Вот моя сущность: < /p>
@Table(name="ballots")
public class Ballot {
@Id
private long id;

@Column
private long meetingId;

@Type(ListArrayType.class)
@Column(name = "companies",columnDefinition = "bigint[]")
private List companies = new ArrayList();
}
< /code>
Вот как я называю метод: < /p>
private final BallotRepository ballotRepo;

public void findBallots(Set companyIds, Set companyMeetingIds) {
List ballots = ballotRepository.findByIds(companyIds, companyMeetingIds);
// the rest of the code
}
}
< /code>
Подпись метода с < /p>
[list]
[*]Long[] companyIds, Long[] meetingIds
работает нормально
[*]

Код: Выделить всё

Long[] companyIds, Collection meetingIds
работает нормально
[*]

Код: Выделить всё

Collection companyIds, Collection meetingIds
не удастся:
[/list]

Код: Выделить всё

org.springframework.dao.InvalidDataAccessResourceUsageException: JDBC exception executing SQL [SELECT * FROM ballots b WHERE b.companies && (?) and b.meeting_id in (?,?)] [ERROR: operator does not exist: bigint[] && bigint
Hint: No operator matches the given name and argument types. You might need to add explicit type casts.
Position: 42] [n/a]; SQL [n/a]
Как мне изменить запрос, чтобы он работал?


Подробнее здесь: https://stackoverflow.com/questions/797 ... ong-but-no

Вернуться в «JAVA»