A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

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);       
}


请各位大神指点下

0 个回复

您需要登录后才可以回帖 登录 | 加入黑马