Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/371.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从4到5休眠迁移_Java_Hibernate_Named Query - Fatal编程技术网

Java 从4到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

我已经使用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.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中不再工作了?代码完全一样