|
我现在用hibernate,想对一个有联合主键的表的某个字段进行更新,结果给我报异常:org.hibernate.ObjectNotFoundException: No row with the given identifier exists: [com.persistent.Consumpatch#com.persistent.ConsumpatchId@68fd7db3]
我在线等!
我的方法如下:
public boolean updateGroup(int typeid,int producterid,int specid,String branchid){
Session session=HibernateSessionFactory.currentSession();
Transaction tx=session.beginTransaction();
try{
ConsumpatchId conid=new ConsumpatchId();
conid.setTypeid(typeid);
conid.setSpecificid(specid);
conid.setBranchid(branchid);
conid.setConmpatchid(conid.getConmpatchid()+1);
Consumpatch cons=(Consumpatch)session.load(Consumpatch.class,conid);
cons.setProducerid(producterid);
session.saveOrUpdate(cons);
session.flush();
tx.commit();
}catch(HibernateException he){
if(tx!=null)
tx.rollback();
he.printStackTrace();
return false;
}finally{
session.close();
}
return true;
} |
|