ORM(Object Relational Mapping) in Hibernate
是你澄清一個很好的例子!
對於類似問題:Is a class diagram essentially a database design? and Are classes the equivalent to tables and their attributes equivalent to columns?
..是 讓我跟你解釋一個例子:在使用這些實體
class Department
{
private int departmentNo;
private int departmentName;
private Set<Student> students;
}
class Student
{
private int studentId;
private int studentName;
private Department department;
}
, Two database tables
將與休眠生成。默認情況下,
Department: departmentno(int),departmentname(varchar(255))
Student: studentid(int), studentname(varchar(255)),departmentno(int) [foreign key]
生成。
特定部門的學生名單可通過retrived,
Department department = ......; // hibernate related thing which hit the database
Set<Student> = department.getStudents();
哈,我在寫同樣的中間!是的,這 - 並搜索ORM,試圖解決這個問題。 – halfer
謝謝你爲我清理:) – MohsinG
好吧,好東西。很高興有幫助。 –