日期:2014-05-18 浏览次数:20692 次
public void insert(){
System.out.println("插入的是insert");
Session session = sessionFactory.openSession();
Transaction tr = session.beginTransaction();
Teacher tea = new Teacher("t22", "老师222");
Course cou = new Course("c22", "课程", tea);
tea.getCourseSet().add(cou);
session.save(cou);
tr.commit();
session.close();
}
public void insertTeacher(){这样就会报错,为什么呀
System.out.println("插入的是Teacher");
Session session = sessionFactory.openSession();
Transaction tr = session.beginTransaction();
Teacher tea = new Teacher("t22", "老师222");
session.save(tea);
tr.commit();
session.close();
}