在hibernate中,查询记录可这样查 Session session = HibernateUtil.getSession();
String hql =
"select distinct c " +
"from Category c join fetch c.subCats " +
"where c.parentId=1";
Query query = session.createQuery(hql);现问:1 修改记录是不是只要在hql中,写修改语句就可?
2 也就用 session.createQuery方法去执行吗
3 增加和删除记录呢,怎么弄
thanks
String hql =
"select distinct c " +
"from Category c join fetch c.subCats " +
"where c.parentId=1";
Query query = session.createQuery(hql);现问:1 修改记录是不是只要在hql中,写修改语句就可?
2 也就用 session.createQuery方法去执行吗
3 增加和删除记录呢,怎么弄
thanks
用session.update方法
增加session.save和删除session.remove一样,写对hql就可以了