title: SQL0407:Null values not allowed in column or variable for JPA spring data insert operation
body: <p>I am having a transaction using spring data , and I am trying to do an save operation (insert operation) . But I am getting [SQL0407] Null values not allowed in column or variable TLLMTS.</p>
  
  <p>Following is the entity</p>
  
  <pre><code>@Entity
  @IdClass(OsytxlId.class)
  @Table(name="OSYTXL")
  @NamedQuery(name="Osytxl.findAll", query="SELECT o FROM Osytxl o")
  public class Osytxl implements Serializable {
      private static final long serialVersionUID = 1L;
  
      @Id
      @Column(name="TLCONO")
      private BigDecimal tlcono;
  
      @Id
      @Column(name="TLDIVI")
      private String tldivi;
  
      @Id
      @Column(name="TLLINO")
      private BigDecimal tllino;
  
      @Column(name="TLLMTS")
      private BigDecimal tllmts;
  
      @Id
      @Column(name="TLLNCD")
      private String tllncd;
  
      @Column(name="TLTX60")
      private String tltx60;
  
      @Id
      @Column(name="TLTXID")
      private BigDecimal tltxid;
  
      @Id
      @Column(name="TLTXVR")
      private String tltxvr;
  
      //getter and setters
  
  }
  </code></pre>
  
  <p>And I am calling the following code portion from the service implementation class</p>
  
  <pre><code>            Osytxl osytxl = null;
  
              for (int lineNo = 0; lineNo &lt; lines.length; lineNo++) {
                  osytxl = new Osytxl();
                  osytxl.setTlcono(osytxh.getThcono());
                  osytxl.setTldivi(osytxh.getThdivi());
                  osytxl.setTltxid(osytxh.getThtxid());
                  osytxl.setTltxvr(osytxh.getThtxvr());
                  osytxl.setTllncd(osytxh.getThlncd());
                  osytxl.setTllmts(new BigDecimal("1437651510403"));
                  osytxl.setTllino(new BigDecimal(lineNo+1));
                  osytxl.setTltx60(lines[lineNo]);
                  osytxlList.add(osytxl);
              }
              if(osytxlList.size()&gt;0)
                  osytxlRepository.save(osytxlList);
  </code></pre>
  
  <p>And I am using JPA repository But I am getting the following exception</p>
  
  <pre><code>Hibernate: insert into OSYTXL (TLLMTS, TLTX60, TLCONO, TLDIVI, TLLINO, TLLNCD, TLTXID, TLTXVR) values (?, ?, ?, ?, ?, ?, ?, ?)
  [2015-07-24 22:54:59][http-nio-8080-exec-10][WARN] SQL Error: -407, SQLState: 23502
  [2015-07-24 22:54:59][http-nio-8080-exec-10][ERROR] [SQL0407] Null values not allowed in column or variable TLLMTS.
  [2015-07-24 22:54:59][http-nio-8080-exec-10][INFO] HHH000010: On release of batch it still contained JDBC statements
  [2015-07-24 22:55:01][http-nio-8080-exec-10][DEBUG] Initiating transaction rollback after commit exception
  org.springframework.orm.jpa.JpaSystemException: org.hibernate.exception.ConstraintViolationException: could not execute statement; nested exception is javax.persistence.PersistenceException: org.hibernate.exception.ConstraintViolationException: could not execute statement
      at org.springframework.orm.jpa.EntityManagerFactoryUtils.convertJpaAccessExceptionIfPossible(EntityManagerFactoryUtils.java:415) ~[spring-orm-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.orm.jpa.DefaultJpaDialect.translateExceptionIfPossible(DefaultJpaDialect.java:122) ~[spring-orm-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:521) ~[spring-orm-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:757) [spring-tx-4.1.6.RELEASE.jar:?]
      at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:726) [spring-tx-4.1.6.RELEASE.jar:?]
      at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:521) [spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:291) [spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:96) [spring-tx-4.1.6.RELEASE.jar:4.1.6.RELEASE]
      at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179) [spring-aop-4.1.6.RELEASE.jar:?]
      at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:207) [spring-aop-4.1.6.RELEASE.jar:?]
      at c
  
  ........................................................
  
  
  
  Caused by: java.sql.SQLIntegrityConstraintViolationException: [SQL0407] Null values not allowed in column or variable TLLMTS.
      at com.ibm.as400.access.JDError.createSQLExceptionSubClass(JDError.java:855) ~[jt400-8.3.jar:JTOpen 8.3]
      at com.ibm.as400.access.JDError.throwSQLException(JDError.java:706) ~[jt400-8.3.jar:JTOpen 8.3]
      at com.ibm.as400.access.JDError.throwSQLException(JDError.java:676) ~[jt400-8.3.jar:JTOpen 8.3]
  </code></pre>
  
  <p>Once the save operation is called , it successfully executing select operation , but seems like its not persisting the changes to the Entity bean object .</p>
  
  <p>And database is set up like this</p>
  
  <pre><code>CREATE TABLE "M3FDBDEM"."OSYTXL"(
  TLCONO DECIMAL default '0' not null,
  TLDIVI NCHAR default '''' not null,
  TLTXID DECIMAL default '0' not null,
  TLTXVR NCHAR default '''' not null,
  TLLNCD NCHAR default '''' not null,
  TLLINO DECIMAL default '0' not null,
  TLTX60 NCHAR default '''' not null,
  TLLMTS DECIMAL default '0' not null)
  </code></pre>
  
  <p>I think i am doing in right way . Can anyone help .</p>