读书人

OneToMany 当中表关联

发布时间: 2012-09-06 10:37:01 作者: rapoo

OneToMany 中间表关联

Class

@Testpublic void testOneToManyJoinTable() {session.beginTransaction();OneToMany.joinTable.Class c = new OneToMany.joinTable.Class();c.setClassName("classNmae");OneToMany.joinTable.Student s1 = new OneToMany.joinTable.Student();OneToMany.joinTable.Student s2 = new OneToMany.joinTable.Student();OneToMany.joinTable.Student s3 = new OneToMany.joinTable.Student();s1.setStudentName("s1");s2.setStudentName("s1");s3.setStudentName("s1");c.getStudents().add(s3);c.getStudents().add(s2);c.getStudents().add(s1);s3.setMyclass(c);s2.setMyclass(c);s1.setMyclass(c);session.save(c);session.getTransaction().commit();}

?

读书人网 >软件架构设计

热点推荐