日期:2014-05-18  浏览次数:20800 次

struts+hibernate 问题(急)
operate.java   代码
public   class   operate   {
private   Session   session=null;
SessionFactory   factory=new   Configuration().configure().buildSessionFactory();
public   static   final   ThreadLocal   thread=new   ThreadLocal();
        public   Session   currentsession(){
        session=(Session)thread.get();
        if(session==null){
        session=factory.openSession();
        thread.set(session);
        }
        return   session;
        }
       
        public   void   closesession(){
        session=(Session)thread.get();
        if(session!=null)
        session.close();
        thread.set(null);
        }
}

saveteam.java
public   class   saveteam   {
Transaction   tran=null;  
operate   op=new   operate();
  private   Session   session=null;
  ActionMessages   errors=new   ActionMessages();
  public   void   insert(Team   team){
          try{
  session=op.currentsession();
        Transaction   tran=session.beginTransaction();
        session.save(team);
        tran.commit();
       
          }catch(Exception   ex){
          ex.printStackTrace();
          tran.rollback();
          }finally{
          op.closesession();
          }
      }
}
TeamAction.java
public   ActionForward   execute(ActionMapping   mapping,   ActionForm   form,
HttpServletRequest   request,   HttpServletResponse   response)   {
TeamForm   teamForm   =   (TeamForm)   form;//   TODO   Auto-generated   method   stub
ActionMessages   errors=new   ActionMessages();
Team   tm=new   Team();
tm.setId(teamForm.getId());
tm.setTeamId(teamForm.getTeam_id());
System.out.println(tm.getId());
System.out.println(tm.getTeamId());
try{
saveteam   stm=new   saveteam();
stm.insert(tm);
}catch(Exception   ex){
ex.printStackTrace(System.out);
errors.add(ActionMessages.GLOBAL_MESSAGE,   new   ActionMessage( "error.insert.failed "));
}
if(!errors.isEmpty()){
saveMessages(request,errors);
return(new   ActionForward(mapping.getInput()));
}
ActionMessages   actionmessages=new   ActionMessages();
actionmessages.add(ActionMessages.GLOBAL_MESSAGE,   new   ActionMessage( "record.inserted "));
saveMessages(request,actionmessages);
return   mapping.findForward( "sucess ");
}
}

为什么插入数据的时候说
SQL   Error: