SSH2中DAO层HQL数据更新方法
1. Add方法
public boolean addQuestion(Question question){ boolean bFlag = false; Date sysDate = getDate(); question.setCreateDate(MyDateFormat.doFormat(sysDate)); try { this.getSession().clear(); this.getHibernateTemplate().save(question); bFlag = true; } catch (HibernateException e) { e.printStackTrace(); throw e; } return bFlag;}
public boolean updateQuestion(Question question) { boolean bFlag = false; Date sysDate = getDate(); question.setModifyDate(MyDateFormat.doFormat(sysDate)); try { this.getSession().clear(); this.getHibernateTemplate().update(question); bFlag = true; } catch (HibernateException e) { e.printStackTrace(); throw e; } return bFlag;}
public boolean deleteQuestion(Question question) { boolean bFlag = false; try { this.getSession().clear(); this.getHibernateTemplate().delete(question); bFlag = true; } catch (HibernateException e) { e.printStackTrace(); throw e; } return bFlag;}
public boolean saveOrUpdate(Question question) { boolean bFlag = false; try { this.getSession().clear(); this.getHibernateTemplate().saveOrUpdate(question); bFlag = true; } catch (HibernateException e) { e.printStackTrace(); throw e; } return bFlag;}