Java 从4到5休眠迁移
我已经使用Hibernate 4很长时间了,现在我需要升级到Hibernate 5,我现在遇到一些命名查询的问题:Java 从4到5休眠迁移,java,hibernate,named-query,Java,Hibernate,Named Query,我已经使用Hibernate 4很长时间了,现在我需要升级到Hibernate 5,我现在遇到一些命名查询的问题: ERROR: HHH000177: Error in named query: findByNumHeure org.hibernate.hql.internal.ast.QuerySyntaxException: Unable to locate appropriate constructor on class [ch.plugin.plugin.entity.Reserva
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)]
@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)"),
这是我的命名查询:
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)]
@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)"),
当然,我有一个构造函数:
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();
}
所以我的问题是:为什么它在Hibernate4中工作得很好,而现在它在Hibernate5中不再工作了?代码完全一样