私のエンティティ「介入」に対して次の名前付きクエリがあります。
@NamedQuery(name = "Intervention.findNextMission", query = " SELECT i FROM Intervention i WHERE i.heureDebut> :DateToBeSpecified and i.idAgent= :idAgent")`
私は2つのパラメータを渡すことによって私のコードでこのクエリを呼び出す方法を知りません:date、id. 通常は次のようになります。
List <Intervention> ListOfInterventions = em.createNamedQuery("Intervention.findNextMission").setParameter().getResultList();
setParameter() の括弧の間に何を入れますか??
ここで私のエンティティ Intervention のコードに従ってください:
@Entity
@Table(name = "intervention")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "Intervention.findAll", query = "SELECT i FROM Intervention i"),
@NamedQuery(name = "Intervention.findByIdIntervention", query = "SELECT i FROM Intervention i WHERE i.idIntervention = :idIntervention"),
@NamedQuery(name = "Intervention.findByHeureDebut", query = "SELECT i FROM Intervention i WHERE i.heureDebut = :heureDebut"),
@NamedQuery(name = "Intervention.findByHeureFin", query = "SELECT i FROM Intervention i WHERE i.heureFin = :heureFin"),
@NamedQuery(name = "Intervention.findNextMission", query = " SELECT i FROM Intervention i WHERE i.heureDebut> :DateToBeSpecified and i.idAgent= :idAgent")})
public class Intervention implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 50)
@Column(name = "IdIntervention", nullable = false, length = 50)
private String idIntervention;
@Basic(optional = false)
@NotNull
@Column(name = "HeureDebut", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date heureDebut;
@Basic(optional = false)
@NotNull
@Column(name = "HeureFin", nullable = false)
@Temporal(TemporalType.TIMESTAMP)
private Date heureFin;
@Lob
@Size(max = 65535)
@Column(name = "NotesGeneral", length = 65535)
private String notesGeneral;
@JoinColumn(name = "IdValidation", referencedColumnName = "IdValidation", nullable = false)
@ManyToOne(optional = false)
private Tablevalidation idValidation;
@JoinColumn(name = "IdNatureIntervention", referencedColumnName = "IdNatureIntervention", nullable = false)
@ManyToOne(optional = false)
private Tablenatureintervention idNatureIntervention;
@JoinColumn(name = "IdAgent", referencedColumnName = "IdAgent", nullable = false)
@ManyToOne(optional = false)
private Agent idAgent;
@JoinColumn(name = "RefContrat", referencedColumnName = "RefContrat", nullable = false)
@ManyToOne(optional = false)
private Projet refContrat;
public Intervention() {
}
//getters and setters
}