1 Reply Latest reply on Mar 1, 2011 5:42 AM by Adam Warski

    can't inter into table with column identity

    Richfacesfan Fanatic Newbie

      hi i have this table hibernate

      public class PlaBonoPorcentual  implements java.io.Serializable {

       

       

           private int codBonoP;

       

           private String nomBonoP;

           private double pjeBonoP;

       

       

          public PlaBonoPorcentual() {

          }

       

       

          public PlaBonoPorcentual(int codBonoP, String nomBonoP, double pjeBonoP) {

             this.codBonoP = codBonoP;

             this.nomBonoP = nomBonoP;

             this.pjeBonoP = pjeBonoP;

          }

       

          public int getCodBonoP() {

              return this.codBonoP;

          }

       

          public void setCodBonoP(int codBonoP) {

              this.codBonoP = codBonoP;

          }

          public String getNomBonoP() {

              return this.nomBonoP;

          }

       

          public void setNomBonoP(String nomBonoP) {

              this.nomBonoP = nomBonoP;

          }

          public double getPjeBonoP() {

              return this.pjeBonoP;

          }

       

          public void setPjeBonoP(double pjeBonoP) {

              this.pjeBonoP = pjeBonoP;

          }

       

      and

      hbm

      <?xml version="1.0" encoding="UTF-8"?>

      <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">

      <!-- Generated 19-feb-2011 22:11:49 by Hibernate Tools 3.2.1.GA -->

      <hibernate-mapping>

        <class catalog="SCI_RRHH" name="org.osbosoftware.planillas.model.bonosporcentuales.PlaBonoPorcentual" schema="dbo" table="PLA_BONO_PORCENTUAL">

          <id name="codBonoP" type="int">

            <column  name="cod_bono_p"/>

            <generator  class="assigned"/>

          </id>

          <property name="nomBonoP" type="string">

            <column length="30" name="nom_bono_p" not-null="true"/>

          </property>

          <property name="pjeBonoP" type="double">

            <column name="pje_bono_p" not-null="true" precision="53" scale="0"/>

          </property>

        </class>

      </hibernate-mapping>

       

      i get this error :

       

      javax.faces.el.EvaluationException: org.hibernate.exception.ConstraintViolationException: could not insert: [org.osbosoftware.planillas.model.bonosporcentuales.PlaBonoPorcentual]
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:102)
      at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:102)
      at javax.faces.component.UICommand.broadcast(UICommand.java:315)
      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:775)
      at javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:1267)
      at com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:82)
      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)
      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118)
      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:393)
      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
      at org.apache.coyote.http11.Http11AprProcessor.process(Http11AprProcessor.java:859)
      at org.apache.coyote.http11.Http11AprProtocol$Http11ConnectionHandler.process(Http11AprProtocol.java:579)
      at org.apache.tomcat.util.net.AprEndpoint$Worker.run(AprEndpoint.java:1555)
      at java.lang.Thread.run(Thread.java:662)
      Caused by: org.hibernate.exception.ConstraintViolationException: could not insert: [org.osbosoftware.planillas.model.bonosporcentuales.PlaBonoPorcentual]
      at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:71)
      at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2267)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2660)
      at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:56)
      at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:250)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:234)
      at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:141)
      at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:298)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1000)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:338)
      at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:106)
      at org.osbosoftware.planillas.model.usuario.Usuarios.autentificar(Usuarios.java:165)
      at org.osbosoftware.planillas.controlador.Login.verificar(Login.java:63)
      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:597)
      at org.apache.el.parser.AstValue.invoke(AstValue.java:191)
      at org.apache.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:276)
      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:98)
      at javax.faces.component.MethodBindingMethodExpressionAdapter.invoke(MethodBindingMethodExpressionAdapter.java:88)
      ... 23 more
      Caused by: java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC][SQLServer]Cannot insert explicit value for identity column in table 'PLA_BONO_PORCENTUAL' when IDENTITY_INSERT is set to OFF.
      at com.microsoft.jdbc.base.BaseExceptions.createException(Unknown Source)
      at com.microsoft.jdbc.base.BaseExceptions.getException(Unknown Source)
      at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processErrorToken(Unknown Source)
      at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReplyToken(Unknown Source)
      at com.microsoft.jdbc.sqlserver.tds.TDSRPCRequest.processReplyToken(Unknown Source)
      at com.microsoft.jdbc.sqlserver.tds.TDSRequest.processReply(Unknown Source)
      at com.microsoft.jdbc.sqlserver.SQLServerImplStatement.getNextResultType(Unknown Source)
      at com.microsoft.jdbc.base.BaseStatement.commonTransitionToState(Unknown Source)
      at com.microsoft.jdbc.base.BaseStatement.postImplExecute(Unknown Source)
      at com.microsoft.jdbc.base.BasePreparedStatement.postImplExecute(Unknown Source)
      at com.microsoft.jdbc.base.BaseStatement.commonExecute(Unknown Source)
      at com.microsoft.jdbc.base.BaseStatement.executeUpdateInternal(Unknown Source)
      at com.microsoft.jdbc.base.BasePreparedStatement.executeUpdate(Unknown Source)
      at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:23)
      at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:2247)
      ... 43 more

       

       

      which anottation ??

      help please..

      richfacesfaces fan