@Entity @Table(name = "employees") public class Employee { @Id private int id; @Column(name = "name") private String name; } @Entity @Table(name = "departments") public class Department { @Id private int id; @OneToMany(mappedBy = "department") private List<Employee> employees; } <hibernate-configuration> <session-factory> <mapping class="com.example.Employee" /> <mapping class="com.example.Department" /> </session-factory> </hibernate-configuration>


上一篇:
下一篇:
切换中文