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

(******)struts+hibernate+oracle9i在添加程序与修改程序中包错,请大家帮下忙,多谢(******)
(******)struts+hibernate+oracle9i在添加程序与修改程序中包错,请大家帮下忙,多谢(******)

Userlist.hbm.xml
里面映射的id如下,数据库是oracle9i,id在表里的类型是number(20)
<id   name= "id "   type= "java.lang.String ">
      <column   name= "ID "   precision= "20 "   scale= "0 "   />
      <generator   class= "increment "   />
</id>
1、当type= "java.lang.String "时,更新程序传过去的id值不错,但是添加是出错
错误是

------------------------------------------------
javax.servlet.ServletException:   this   id   generator   generates   long,   integer,   short
org.apache.struts.action.RequestProcessor.processException(RequestProcessor.java:523)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:421)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.newstong.web.filters.SetEncodingFilter.doFilter(SetEncodingFilter.java:62)


root   cause  

org.hibernate.id.IdentifierGenerationException:   this   id   generator   generates   long,   integer,   short
org.hibernate.id.IdentifierGeneratorFactory.createNumber(IdentifierGeneratorFactory.java:119)
org.hibernate.id.IncrementGenerator.generate(IncrementGenerator.java:47)
org.hibernate.event.def.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:85)


org.hibernate.event.def.DefaultSaveOrUpdateEventListener.saveWithGeneratedOrRequestedId(DefaultSaveOrUpdateEventListener.java

:184)
org.hibernate.event.def.DefaultSaveEventListener.saveWithGeneratedOrRequestedId(DefaultSaveEventListener.java:33)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.entityIsTransient(DefaultSaveOrUpdateEventListener.java:173)
org.hibernate.event.def.DefaultSaveEventListener.performSaveOrUpdate(DefaultSaveEventListener.java:27)
org.hibernate.event.def.DefaultSaveOrUpdateEventListener.onSaveOrUpdate(DefaultSaveOrUpdateEventListener.java:69)
org.hibernate.impl.SessionImpl.save(SessionImpl.java:481)
org.hibernate.impl.SessionImpl.save(SessionImpl.java:476)
com.newstong.web.struts.action.AddStudent.execute(AddStudent.java:87)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
com.newstong.web.filters.SetEncodingFilter.doFilter(SetEncodingFilter.java:62)
note   The   full   stack   trace   of   the   root   cause   is   available   in   the   Apache   Tomcat/5.0.28   logs.
----------------------------------------------------
2、当type= "java.lang.Long "时,是添加是不出错,但更新程序传过去的id值出错,