我用struts+hibernate开发,出现这样的问题。
我更新数据时,出现这以下情况:
org.hibernate.NonUniqueObjectException: a different object with the same identif
ier value was already associated with the session: [ok.pojo.Text#1]原来代码是这样子的:
UpdateAction.java
ShowService ss=new ShowService();
long id=Long.parseLong(request.getParameter("id"));
System.out.println(id);
Text text=new Text();
text.setTitle(request.getParameter("title"));
text.setContext(request.getParameter("context"));
text.setId(new Long(id));
boolean re=ss.updataText(text);
return mapping.findForward("show");Showservice.java
public boolean updataText(Text text)
    {
     s=SessionFactory.currentSession();
     Transaction tx=s.beginTransaction();
     try{
    
        System.out.println(text.getTitle()+":::"+text.getContext());
        s.saveOrUpdate(text);
        s.flush();
        tx.commit();
     }catch(HibernateException e){
     e.printStackTrace(System.out);
     tx.rollback();
     return false;
     }
     return true;
    }