I have used Hibernate 4 since a long time and now I need to upgrade to hibernate 5 and I have some trouble now with some named query:
ERROR: HHH000177: Error in named query: findByNumHeure
org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [ch.plugin.plugin.entity.Reservation]. Expected arguments are: ch.plugin.plugin.entity.Reservation, long [SELECT new Reservation(r, COUNT(r.numeroReservation)) FROM ch.plugin.plugin.entity.Reservation r WHERE r.numeroReservation =:num and r.reservationPK.heureDebutReservation = :heure GROUP BY r.numeroReservation HAVING r.reservationPK.heureDebutReservation = min(r.reservationPK.heureDebutReservation)]
and this is my named query:
@NamedQuery(name = "findByNumHeure", query = "SELECT new Reservation(r, COUNT(r.numeroReservation)) FROM Reservation r WHERE r.numeroReservation =:num and r.reservationPK.heureDebutReservation = :heure GROUP BY r.numeroReservation HAVING r.reservationPK.heureDebutReservation = min(r.reservationPK.heureDebutReservation)"),
and of course, I have this constructor:
public Reservation() {
}
public Reservation(Reservation reservation, Long etat) {
this.reservationPK = reservation.getReservationPK();
this.couleurReservation = reservation.getCouleurReservation();
this.iDRecurrence = reservation.getIDRecurrence();
this.isPaye = reservation.getIsPaye();
this.numeroReservation = reservation.getNumeroReservation();
this.responsable = reservation.getResponsable();
this.texte = reservation.getTexte();
this.etat = etat.intValue();
this.prix = reservation.getPrix();
}
So my question is: Why it was working well in Hibernate 4 and now this is not working any more with Hibernate 5? And the code is exactly the same?