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
This problem has nothing to do with spring
This problem has nothing to do with JPA or Hibernate
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