I'm trying to make a search on the date based on a list of possible dates the user can pick from. With a calendar I ask the user to input a date and then I want to get all the possible packets who have that date in their "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 the logs of the server 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 DataPossibilePP is:
@Entity
@IdClass(DataPossibilePPPK.class)
public class DataPossibilePP implements Serializable {
@Id
private Integer id_pp;
@Id
private Date data;
private static final long serialVersionUID = 1L;
/*standard getters and setters*/
}
I don't understand why I'm told the field is not a collection, even if it is defined as a list and Eclipse itself suggests me it in its autocomplete.
How could I write the query so that it compiles?