Requête avec JPQL select avec condition des dates
Bonjour,
je veux faire une requete select avec jpql
my DAOImpl:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
@Transactional
public Long sumNb5xx() {
/*Création d'un objet Query requete calcul somme de classe de réponse 5XX*/
Query q5xx = em.createQuery("SELECT SUM(h.nb5xx) FROM HttpEntity h WHERE h.host = :host and h.date_http BETWEEN :startDate and :endDate");
q5xx.setParameter("host","megaupload.com" );
q5xx.setParameter("startDate", "17/03/2014 21:00:00");
q5xx.setParameter("endDate", "16/03/2014 21:00:00");
//Exécution et récupération du resultat du requete
Long sum5xx = (Long) q5xx.getSingleResult();
return sum5xx;
} |
l'initialisation des attributes dans ma classe entité :
Code:
1 2 3 4 5 6 7 8
|
@Column(name="HOST")
private String host;
@Column(name="DATE_HTTP", insertable=false, updatable=false, columnDefinition="TIMESTAMP DEFAULT CURRENT_TIMESTAMP")
@Temporal(TemporalType.TIMESTAMP)
private Date date_http; |
j'ai un erreur :
Code:
1 2 3
|
SEVERE: Servlet.service() for servlet [Faces Servlet] in context with path [/kpi] threw exception [Error creating bean with name 'httpMB': Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Parameter value [17/03/2014 21:00:00] did not match expected type [java.util.Date (n/a)]] with root cause
java.lang.IllegalArgumentException: Parameter value [17/03/2014 21:00:00] did not match expected type [java.util.Date (n/a)] |
merci d'avance pour ton aide