带有嵌套对象的HQL查询中的问题

时间:2018-11-03 00:11:35

标签: hibernate jpa

我有这两个类和一个用于插入数据的代码:

type

我想查询一个学生类的所有测验,如下所示:

@Entity
@Table(name = "quiz_test")
public class QuizTest implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;

    @OneToOne
    @JoinColumn(name = "quiz_id")
    private Quiz quiz;


@Entity(name = "Quiz")
@Table(name = "quiz")
@PrimaryKeyJoinColumn(name="id")
public class Quiz implements Serializable {
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;


    @ManyToMany(fetch = FetchType.EAGER, cascade=CascadeType.ALL)
    private List<StudentClass> stClasses= new ArrayList<>();

但是我有这个错误:

  

org.hibernate.QueryException:预期的位置参数数:1,实际参数:[StudentClass [id = 2,name = Seconde A,startDate = 2018-06-27,endDate = 2018-11-05,students = [ fr.dawan.autoquiz3000.beans.User @ c1f72974,fr.dawan.autoquiz3000.beans.User @ b15245c3,fr.dawan.autoquiz3000.beans.User @ 7f943dc1,fr.dawan.autoquiz3000.beans.User @ 9eaa7d67,fr。 dawan.autoquiz3000.beans.User @ e7d21a2c,fr.dawan.autoquiz3000.beans.User @ cfbe7565],版本= 7]] [从QuizTest qt内部联接qt.quiz q在哪里q.stClasses =?]

有人可以向我解释我在做错什么!

谢谢!

0 个答案:

没有答案