2 Replies Latest reply on Oct 17, 2005 2:54 AM by wang haiwen

    Use SQL Server 2000 @Id(generate=GeneratorType.IDENTITY)  er

    wang haiwen Newbie

      @Entity
      @Table(name="autodemo")
      public class AutoDemo{
      private int autoId;
      @Id(generate=GeneratorType.IDENTITY)
      @Column(name="autoId",insertable=true,updatable=false)
      public int getAutoId(){
      return autoId;
      }
      public void setAutoId(int autoId){
      this.autoId = autoId;
      }
      ...
      }


      11:31:55,812 INFO [STDOUT] Hibernate: insert into autodemo (autoContext, autoId) values (?, null)
      11:31:55,828 WARN [JDBCExceptionReporter] SQL Error: 544, SQLState: 23000
      11:31:55,828 ERROR [JDBCExceptionReporter] [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]? IDENTITY_INSERT ??? OFF ?????? 'autoDemo' ???????????
      11:31:55,843 ERROR [[Faces Servlet]] Servlet.service() for servlet Faces Servlet threw exception
      javax.faces.FacesException: Error calling action method of component with id _id0:_id3
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:74)
       at javax.faces.component.UICommand.broadcast(UICommand.java:106)
       at javax.faces.component.UIViewRoot._broadcastForPhase(UIViewRoot.java:90)
       at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:164)
       at org.apache.myfaces.lifecycle.LifecycleImpl.invokeApplication(LifecycleImpl.java:271)
       at org.apache.myfaces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:86)
       at javax.faces.webapp.FacesServlet.service(FacesServlet.java:94)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:252)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:81)
       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:202)
       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:173)
       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:213)
       at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
       at org.jboss.web.tomcat.security.CustomPrincipalValve.invoke(CustomPrincipalValve.java:39)
       at org.jboss.web.tomcat.security.SecurityAssociationValve.invoke(SecurityAssociationValve.java:157)
       at org.jboss.web.tomcat.security.JaccContextValve.invoke(JaccContextValve.java:59)
       at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
       at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
       at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
       at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
       at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:856)
       at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:744)
       at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:527)
       at org.apache.tomcat.util.net.MasterSlaveWorkerThread.run(MasterSlaveWorkerThread.java:112)
       at java.lang.Thread.run(Thread.java:595)
      Caused by: javax.faces.el.EvaluationException: Exception while invoking expression #{autoadd.add}
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:153)
       at org.apache.myfaces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:63)
       ... 25 more
      Caused by: javax.ejb.EJBException: null; CausedByException is:
       could not insert: [govfms.ejb.system.AutoDemo]
       at org.jboss.ejb3.tx.Ejb3TxPolicy.handleExceptionInOurTx(Ejb3TxPolicy.java:46)
       at org.jboss.aspects.tx.TxPolicy.invokeInOurTx(TxPolicy.java:70)
       at org.jboss.aspects.tx.TxInterceptor$Required.invoke(TxInterceptor.java:134)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.aspects.tx.TxPropagationInterceptor.invoke(TxPropagationInterceptor.java:61)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.aspects.security.AuthenticationInterceptor.invoke(AuthenticationInterceptor.java:63)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.ENCPropagationInterceptor.invoke(ENCPropagationInterceptor.java:32)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.asynchronous.AsynchronousInterceptor.invoke(AsynchronousInterceptor.java:91)
       at org.jboss.aop.joinpoint.MethodInvocation.invokeNext(MethodInvocation.java:88)
       at org.jboss.ejb3.stateful.StatefulContainer.localInvoke(StatefulContainer.java:136)
       at org.jboss.ejb3.stateful.StatefulLocalProxy.invoke(StatefulLocalProxy.java:83)
       at $Proxy98.add(Unknown Source)
       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
       at java.lang.reflect.Method.invoke(Method.java:585)
       at org.apache.myfaces.el.MethodBindingImpl.invoke(MethodBindingImpl.java:129)
       ... 26 more
      11:36:25,953 INFO [STDOUT] Exception in thread "Timer-3"
      11:36:25,953 INFO [STDOUT] javax.ejb.EJBException: Could not passivate; failed to save state; CausedByException is:
       govfms.ejb.system.AutoAddAction
      11:36:25,953 INFO [STDOUT] at org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:333)
      11:36:25,968 INFO [STDOUT] at org.jboss.ejb3.cache.simple.SimpleStatefulCache.passivate(SimpleStatefulCache.java:143)
      11:36:25,968 INFO [STDOUT] at org.jboss.ejb3.cache.simple.SimpleStatefulCache$SessionTimeoutTask.run(SimpleStatefulCache.java:92)
      11:36:25,968 INFO [STDOUT] at java.util.TimerThread.mainLoop(Timer.java:512)
      11:36:25,968 INFO [STDOUT] at java.util.TimerThread.run(Timer.java:462)
      11:36:25,968 INFO [STDOUT] java.io.NotSerializableException: govfms.ejb.system.AutoAddAction
      11:36:25,968 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1075)
      11:36:25,968 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      11:36:25,984 INFO [STDOUT] at org.jboss.aop.metadata.SimpleMetaData.writeExternal(SimpleMetaData.java:211)
      11:36:25,984 INFO [STDOUT] at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1304)
      11:36:25,984 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1282)
      11:36:25,984 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      11:36:25,984 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      11:36:25,984 INFO [STDOUT] at java.rmi.MarshalledObject.<init>(MarshalledObject.java:92)
      11:36:25,984 INFO [STDOUT] at org.jboss.ejb3.stateful.StatefulBeanContext.writeExternal(StatefulBeanContext.java:153)
      11:36:25,984 INFO [STDOUT] at java.io.ObjectOutputStream.writeExternalData(ObjectOutputStream.java:1304)
      11:36:25,984 INFO [STDOUT] at java.io.ObjectOutputStream.writeOrdinaryObject(ObjectOutputStream.java:1282)
      11:36:25,984 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject0(ObjectOutputStream.java:1073)
      11:36:25,984 INFO [STDOUT] at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:291)
      11:36:25,984 INFO [STDOUT] at org.jboss.ejb3.cache.simple.StatefulSessionFilePersistenceManager.passivateSession(StatefulSessionFilePersistenceManager.java:324)
      11:36:26,000 INFO [STDOUT] at org.jboss.ejb3.cache.simple.SimpleStatefulCache.passivate(SimpleStatefulCache.java:143)
      11:36:26,000 INFO [STDOUT] at org.jboss.ejb3.cache.simple.SimpleStatefulCache$SessionTimeoutTask.run(SimpleStatefulCache.java:92)
      11:36:26,000 INFO [STDOUT] at java.util.TimerThread.mainLoop(Timer.java:512)
      11:36:26,000 INFO [STDOUT] at java.util.TimerThread.run(Timer.java:462)