我有以下實體:JPA - 選擇多對多場
@Entity
@Data
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@AllArgsConstructor
public class Seat extends AbstractEntity<Long> {
@ManyToOne
private Performance performance;
@ManyToMany
private List<Rate> availableRates;
}
我想在JPQL執行以下查詢:
SELECT DISTINCT s.availableRates FROM Seat s WHERE :performance = s.performance
,但我一直有如下錯誤
無法準備聲明; SQL [select count(distinct。)as col_0_0_ from seat seat0_,seat_available_rates availabler1_,rate rate2_ where seat0_.identifier = availabler1_.seat_identifier and availabler1_.available_rates_identifier = rate2_.identifier and?= seat0_.performance_identifier];嵌套的異常是org.hibernate.exception.SQLGrammarException:無法準備語句
如何編寫正確的查詢?
不能選擇多個值字段,按照JPA規範 –