上面的代码部分应该是:
private void addEmailAddresses2Student(Integer studentId,
String emailAddress)
{
SessionFactory sessionFactory =
new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.getCurrentSession();
Transaction tx = session.beginTransaction();
Student student = (Student) session.load(Student.class, studentId);
student.getEmailAddresses().add(emailAddress);
tx.commit();
session.close();
}
private void addEmailAddresses2Student(Integer studentId,
String emailAddress)
{
SessionFactory sessionFactory =
new Configuration().configure().buildSessionFactory();
Session session = sessionFactory.getCurrentSession();
Transaction tx = session.beginTransaction();
Student student = (Student) session.load(Student.class, studentId);
student.getEmailAddresses().add(emailAddress);
tx.commit();
session.close();
}
还有,对于Tomcat5.5版本好像和文档上说的处理方法不一样,可以参考
http://www.hibernate.org/114.html上面,作者给出了解决方法。