by Anonymous » 19 Aug 2025, 23:37
In einem meiner Springdaten-JPA-Repositories habe ich diese native Abfrage (postgresql): < /p>
Code: Select all
@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>
Hier ist meine Entität: < /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>
Hier erfahren Sie, wie ich die Methode nenne: < /p>
private final BallotRepository ballotRepo;
public void findBallots(Set companyIds, Set companyMeetingIds) {
List ballots = ballotRepository.findByIds(companyIds, companyMeetingIds);
// the rest of the code
}
}
Methodensignatur mit < /p>
[*]Long[] companyIds, Long[] meetingIds
funktioniert gut
[*]
Code: Select all
Long[] companyIds, Collection meetingIds
funktioniert gut
Code: Select all
Collection companyIds, Collection meetingIds
fehl
Code: Select all
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]
Wie soll ich die Abfrage ändern, damit sie funktioniert?
In einem meiner Springdaten-JPA-Repositories habe ich diese native Abfrage (postgresql): < /p>
[code]@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>
Hier ist meine Entität: < /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>
Hier erfahren Sie, wie ich die Methode nenne: < /p>
private final BallotRepository ballotRepo;
public void findBallots(Set companyIds, Set companyMeetingIds) {
List ballots = ballotRepository.findByIds(companyIds, companyMeetingIds);
// the rest of the code
}
}
Methodensignatur mit < /p>
[*]Long[] companyIds, Long[] meetingIds[/code] funktioniert gut
[*][code]Long[] companyIds, Collection meetingIds[/code] funktioniert gut
[code]Collection companyIds, Collection meetingIds[/code] fehl[code]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]
[/code]
Wie soll ich die Abfrage ändern, damit sie funktioniert?