2011年9月2日星期五

Hibernate save, update and delete doesn't work

Hibernate save, update and delete doesn't work.

Solution: add transaction for your codes.

Example:

Transaction tr= getSession().beginTransaction();               
  try {
   getSession().save(transientInstance);
   log.debug("save successful");
   tr.commit();
  } catch (RuntimeException re) {
   log.error("save failed", re);
   tr.rollback();
   throw re;
  }finally
  {
   ;
  }

没有评论:

发表评论