org.hibernate.HibernateException: Illegal attempt to associate a collection with two open sessions
org.hibernate.collection.AbstractPersistentCollection.setCurrentSession(AbstractPersistentCollection.java:410)
org.hibernate.event.def.OnUpdateVisitor.processCollection(OnUpdateVisitor.java:43)
org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:101)
org.hibernate.event.def.AbstractVisitor.processValue(AbstractVisitor.java:61)
org.hibernate.event.def.AbstractVisitor.processEntityPropertyValues(AbstractVisitor.java:55)
org.hibernate.event.def.AbstractVisitor.process(AbstractVisitor.java:123)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.performUpdate(DefaultSaveOrUpdateEventListener.java:293)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsDetached(DefaultSaveOrUpdateEventListener.java:223)
org.hibernate.event.def.DefaultUpdateEventListener.performSaveOrUpdate(DefaultUpdateEventListener.java:33)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:70)
org.hibernate.impl.SessionImpl.fireUpdate(SessionImpl.java:564)
org.hibernate.impl.SessionImpl.update(SessionImpl.java:552)
org.hibernate.impl.SessionImpl.update(SessionImpl.java:544)
vo.dao.daoimp.BuserDAO.updateBuser(BuserDAO.java:61)
vo.action.CreateAnswersAction.updateBuser(CreateAnswersAction.java:82)
vo.action.CreateAnswersAction.execute(CreateAnswersAction.java:152)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:462)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
db.SetCharacterEncodingFilter.doFilter(SetCharacterEncodingFilter.java:78)
dao类
//更新用户
public void updateBuser(Buser buser) throws Exception {
// TODO Auto-generated method stub
this.session.update(buser);
this.session.beginTransaction().commit();
this.session.close();
}
执行方法
public void updateBuser(int mid,String username)throws Exception
{
List mes=null;
String name=null;
Messager m=new Messager();
mes=Information.getMessagerDAO().selectMessager(mid);
for(int i=0;i<mes.size();i++)
{
m=(Messager)mes.get(i);
}
// int bbid=m.getBuser().getBbid();//得到贴主的id
name=m.getMname();
System.out.println("你是条猪——"+name);
if(!(name.equals(username))){
System.out.println("进行用户更新操作!");
//首先给贴主
Buser b=m.getBuser();
System.out.println("发帖者的昵称-----------"+b.getBbsname());
b.setBbid(mid);
b.setBbsnum(b.getBbsnum()+10);
b.setBbsmoods(b.getBbsmoods()+10);
b.setBbsexperience(b.getBbsexperience());
b.setBbsname(b.getBbsname());
b.setBbsimage(b.getBbsimage());
b.setBbsusername(b.getBbsusername());
Information.getBuserDAO().updateBuser(b);
//查询回复者信息