java - How to query through external key in spring?
为情所困
为情所困 2017-05-17 09:58:13
0
2
555

Entity relationship: A teacher has multiple students

@Entity public Teacher class{ @Id private Long id; } @Entity public Student class{ @Id Long id; @ManyToOne private Teacher teacher; }

At this time, the database will automatically generate the foreign key of teacher_id in the student table, but if I know the teacherId, how can I query all the students of this teacher? By external teacher_id

为情所困
为情所困

reply all (2)
世界只因有你
  1. This problem has nothing to do with spring

  2. This problem has nothing to do with JPA or Hibernate

  3. This problem is related to the database you are using. Different databases have different methods. I only know how to do it in Oracle, see here

    大家讲道理

    http://docs.spring.io/spring-...
    Method in official documentation

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!