Session session = getHibernateTemplate().getSessionFactory().getCurrentSession();
session.beginTransaction();
Integer id=UserContext.getUserId();
Date date=new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateString=format.format(date);
String sql="update IosaSectionDO t set t.chiefAuditor='"+userId+"' , t.last_modifier="+id+" ,t.lastUpdate=to_date('"+dateString+"','YYYY/MM/DD HH24:MI:SS') where t.id="+sectionId;
Query query = session.createQuery(sql);
int i=query.executeUpdate();
session.getTransaction().commit();
这种样式转换成内部update的实现,应该怎么写,我写了一个一直报错:
String hql="from IosaSectionDO t where t.sectionId=?";
List<IosaSectionDO>lists=this.getHibernateTemplate().find(hql,Integer.valueOf(sectionId));
//Map<String,Object>map=new HashMap<String,Object>();
if(lists.size()>0){
IosaSectionDO iac=new IosaSectionDO();
iac.setChiefAuditor(lists.get(0).getChiefAuditor());
this.update(iac);
}
请各位大神指点下
|
|