title: Why does my update throw a hibernate ConstraintViolationException?
body: <pre><code>CREATE TABLE GUSERPRO
  (
    USER_NAME      VARCHAR2(20 BYTE),
    SYSTEM         VARCHAR2(8 BYTE),
    PROCESS        VARCHAR2(8 BYTE),
    LOGIN_TIME     NUMBER,
    LOGIN_DATE     DATE,
    LOGOUT_TIME    NUMBER,
    LOGOUT_DATE    DATE,
    TOTAL_ELAPSED  NUMBER,
    TOTAL_LOGINS   NUMBER
  )
  TABLESPACE ERIP_D
  PCTUSED    0
  PCTFREE    10
  INITRANS   1
  MAXTRANS   255
  STORAGE    (
              INITIAL          64K
              NEXT             1M
              MINEXTENTS       1
              MAXEXTENTS       2147483645
              PCTINCREASE      0
              BUFFER_POOL      DEFAULT
             )
  LOGGING 
  NOCOMPRESS 
  NOCACHE
  NOPARALLEL
  MONITORING
  ENABLE ROW MOVEMENT;
  </code></pre>
  
  <p>the exception stack references this constraint:</p>
  
  <pre><code>CREATE UNIQUE INDEX GUSERPRO_N1 ON GUSERPRO
  (USER_NAME, SYSTEM, PROCESS)
  LOGGING
  TABLESPACE ERIP_D
  PCTFREE    10
  INITRANS   2
  MAXTRANS   255
  STORAGE    (
              INITIAL          64K
              NEXT             1M
              MINEXTENTS       1
              MAXEXTENTS       2147483645
              PCTINCREASE      0
              BUFFER_POOL      DEFAULT
             )
  NOPARALLEL;
  </code></pre>
  
  <p>while trying to update a record into the Oracle database I am getting this error, but not always , some scenarios I get this error. If I create a new record and then update it is working fine. If I try to update the existing record it is throwing this error.
  Please help me to get rid of this.</p>
  
  <pre><code>org.springframework.dao.DataIntegrityViolationException: 
     Could not execute JDBC batch update; 
     SQL [update PDOXDATA_GUSERPRO set PROCESS=?, SYSTEM=? where USER_NAME=?]; 
     constraint [PDOXDATA_GUSERPRO_N1]; 
  
  nested exception is org.hibernate.exception.ConstraintViolationException: 
      Could not execute JDBC batch update
      &lt;&lt; rest of error stack &gt;&gt;
  </code></pre>
  
  <p>Here is the relevant class:</p>
  
  <pre><code>/**
   * 
   */
  package com.lv.rs.accessautomation.common.vo;
  
  import java.io.Serializable;
  import java.util.ArrayList;
  import java.util.List;
  
  import javax.persistence.CascadeType;
  import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.FetchType;
  import javax.persistence.Id;
  import javax.persistence.JoinColumn;
  import javax.persistence.OneToMany;
  import javax.persistence.Table;
  import javax.persistence.UniqueConstraint;
  
  /**
   * @author tp50148
   *
   */
  @Entity
  @Table(name="PDOXDATA_GUSERPRO"/*,uniqueConstraints = {@UniqueConstraint(columnNames = "userName")}*/)
  public class EripUserProVO implements Serializable{
  
      /**
       * 
       */
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name = "USER_NAME")
      private String userName;
  
      @Column(name = "SYSTEM")
      private String system;
  
      @Column(name = "PROCESS")
      private String process;
  
      @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,orphanRemoval = true)
      @JoinColumn(name="USER_NAME")
      private List&lt;EripGtSignatVO&gt; eripGtSignatVO = new ArrayList&lt;EripGtSignatVO&gt;();
  
      @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,orphanRemoval = true)
      @JoinColumn(name="USER_NAME")
      private List&lt;EripGUsersVO&gt; eripGUsersVO = new ArrayList&lt;EripGUsersVO&gt;();
  
      @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,orphanRemoval = true)
      @JoinColumn(name="USERNAME")
      private List&lt;EripUserLocationVO&gt; eripUserLocationVO = new ArrayList&lt;EripUserLocationVO&gt;();
  
      @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,orphanRemoval = true)
      @JoinColumn(name="USER_USER")
      private List&lt;Eripcpa95VO&gt; eripcpa95VO = new ArrayList&lt;Eripcpa95VO&gt;();
  
      @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,orphanRemoval = true)
      @JoinColumn(name="USERNAME")
      private List&lt;EriporaSacUserVO&gt; eriporaSacUserVO = new ArrayList&lt;EriporaSacUserVO&gt;();
  
      @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY,orphanRemoval = true)
      @JoinColumn(name="SACUSER_USERNAME")
      private List&lt;EriporaSacAccessVO&gt; eriporaSacAccessVO = new ArrayList&lt;EriporaSacAccessVO&gt;();
  
      public String getUserName() {
          return userName;
      }
      public void setUserName(String userName) {
          this.userName = userName;
      }
      public String getSystem() {
          return system;
      }
      public void setSystem(String system) {
          this.system = system;
      }
      public String getProcess() {
          return process;
      }
      public void setProcess(String process) {
          this.process = process;
      }
      public List&lt;EripGtSignatVO&gt; getEripGtSignatVO() {
          return eripGtSignatVO;
      }
      public void setEripGtSignatVO(List&lt;EripGtSignatVO&gt; eripGtSignatVO) {
          this.eripGtSignatVO = eripGtSignatVO;
      }
      public List&lt;EripGUsersVO&gt; getEripGUsersVO() {
          return eripGUsersVO;
      }
      public void setEripGUsersVO(List&lt;EripGUsersVO&gt; eripGUsersVO) {
          this.eripGUsersVO = eripGUsersVO;
      }
      public List&lt;EripUserLocationVO&gt; getEripUserLocationVO() {
          return eripUserLocationVO;
      }
      public void setEripUserLocationVO(List&lt;EripUserLocationVO&gt; eripUserLocationVO) {
          this.eripUserLocationVO = eripUserLocationVO;
      }
      public List&lt;Eripcpa95VO&gt; getEripcpa95VO() {
          return eripcpa95VO;
      }
      public void setEripcpa95VO(List&lt;Eripcpa95VO&gt; eripcpa95vo) {
          eripcpa95VO = eripcpa95vo;
      }
      public List&lt;EriporaSacUserVO&gt; getEriporaSacUserVO() {
          return eriporaSacUserVO;
      }
      public void setEriporaSacUserVO(List&lt;EriporaSacUserVO&gt; eriporaSacUserVO) {
          this.eriporaSacUserVO = eriporaSacUserVO;
      }
      public List&lt;EriporaSacAccessVO&gt; getEriporaSacAccessVO() {
          return eriporaSacAccessVO;
      }
      public void setEriporaSacAccessVO(List&lt;EriporaSacAccessVO&gt; eriporaSacAccessVO) {
          this.eriporaSacAccessVO = eriporaSacAccessVO;
      }
  
  
  
  }
  </code></pre>