PostgreSQL: JPA -Repo -Methode mit native Abfrage, die '&&' nicht akzeptiert, aber Long> aber Long []Java

Java-Forum
Anonymous
 PostgreSQL: JPA -Repo -Methode mit native Abfrage, die '&&' nicht akzeptiert, aber Long> aber Long []

Post by Anonymous »

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
}
}
Sobald ich Long [] CompanyIDs verwende, long [] MeetingIds In der Methode Signatur alles in Ordnung ist. MeetingIds Methodenaufruf beginnt mit
fehlgeschlagen

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?

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post