一个用户登陆系统之后,对于自己的信息进行了修改(多表修改),修改之后,怎样确定修改主表的id,用不用在给这个表id赋值?
我赋值后运行,错误提示为:WARN: SQL Error: 1062, SQLState: 23000
ERROR: Duplicate entry '6166' for key 2.翻译后为键重复.
怎样用update???
我赋值后运行,错误提示为:WARN: SQL Error: 1062, SQLState: 23000
ERROR: Duplicate entry '6166' for key 2.翻译后为键重复.
怎样用update???
如下再修改得到这个实体user.setName("新名字");
主键是不能修改的,所以不用指定;
最后session.update(user);
session.commit();
Profile profile = this.serviceManager.getProfileManager().getProfile(user.getId());
public Profile getProfile(Long userid,String type){
Profile pro=null;
String hql="";
if(type.equals("max")){
hql="from Profile where createTime=(select max(pr.createTime) from Profile pr where pr.user.id='"+userid+"' and pr.valid='muqian' and pr.job.profile is not null)";
this.selectInfor(hql, null,"fufei");
return pro;
}
public void selectInfor(String hql, Object[] o,String pp){
Session session=dao.sf().openSession();
this.list=dao.query(session, hql,o).list();
if(pp.equals("freeff")) {
freeSize = list.size();
}
if (pp.equals("fufeiff")){
size = list.size();
}
session.close();
}
但还是有那个问题
你可以通过id查到对应的实体对象,然后update(对象)