I am trying to search by date based on a list of possible dates that the user can select. In the calendar, I ask the user to enter a date, and then I want to get all the possible packages that have this date in my "data_possibile" list.
This is the query I'm using:
@NamedQuery(name="pacchettoPreconfigurato.findVendibileByData", query="SELECT p FROM PacchettoPreconfigurato p WHERE p.in_vendita=TRUE AND (:data) IN (p.date_possibili)")
Now, when I try to deploy the application in server logs, I get:
Exception Description: Problem compiling [SELECT p FROM PacchettoPreconfigurato p WHERE p.in_vendita=TRUE AND (:data) IN (p.date_possibili)]. [81, 97] The state field path 'p.date_possibili' cannot be resolved to a collection type.
This is how p.date_possibili is defined:
@OneToMany(orphanRemoval=true)
@JoinColumn(name="id_pp")
private List<DataPossibilePP> date_possibili;
where is DataPossibilePP:
@Entity
@IdClass(DataPossibilePPPK.class)
public class DataPossibilePP implements Serializable {
@Id
private Integer id_pp;
@Id
private Date data;
private static final long serialVersionUID = 1L;
}
I don’t understand why they tell me that the field is not a collection, even if it is defined as a list, and Eclipse itself tells me this in its autocomplete.
How can I write a query so that it compiles?
source
share