hibernate 多对多关系详解(包括中间表,一对多字表)
2012-05-25 11:13:59 来源:WEB开发网核心提示:session.getTransaction().commit(); return result;} privatevoid addPersonToEvent(Long personId, Long eventId) { Session session = HibernateUtil.getSessionFactory
session.getTransaction().commit();
return result;
}
privatevoid addPersonToEvent(Long personId, Long eventId) {
Session session = HibernateUtil.getSessionFactory().getCurrentSession();
session.beginTransaction();
Person aPerson = (Person) session
.createQuery("select p from Person p left join fetch p.events where p.id = :pid")
.setParameter("pid", personId)
更多精彩
赞助商链接