title: Cannot insert NULL into column
body: <p>I am attempting to get Hibernate to lazy load some clobs.  The loading portion is working just fine.  The issue is when I try to create a new one.  I started with advice from <a href="https://stackoverflow.com/questions/2605477/spring-hibernate-blob-lazy-loading">Blob lazy loading</a></p>
  <p>Here are my mappings (Note the table structure is really really bad, there are multiple clobs on this table -- this example is simplified from my real model...).</p>
  <pre><code>@Entity @Table(&quot;TABLE_1&quot;)
  public class BadDBDesign {
    @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(&quot;table_id&quot;)
    private long key;
    
    @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = &quot;table_id&quot;, referencedColumnName = &quot;table_id&quot;, 
                insertable = true, updatable = false)
    private BlobWrapperA;
  
    @OneToOne(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
    @JoinColumn(name = &quot;table_id&quot;, referencedColumnName = &quot;table_id&quot;,
                insertable = true, updatable = false)
    private BlobWrapperB;
  }
  
  @Entity @Table(name = &quot;TABLE_1&quot;)
  public class BlobWrapperA {
    @Lob
    @Column(name = &quot;col_A&quot;, nullable = false)
    @Type(type = &quot;org.springframework.orm.hibernate3.support.BlobByteArrayType&quot;)
    private byte[] blobColA;
  
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = &quot;table_id&quot;)
    private long Key;
  }
  
  @Entity @Table(name = &quot;TABLE_1&quot;)
  public class BlobWrapperB {
    @Lob
    @Column(name = &quot;col_B&quot;, nullable = false)
    @Type(type = &quot;org.springframework.orm.hibernate3.support.BlobByteArrayType&quot;)
    private byte[] blobColB;
  
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = &quot;table_id&quot;)
    private long Key;
  }
  </code></pre>
  <p>Application boots just fine, am able to retrieve the data without loading the clobs (am able to retrieve them when needed via lazy loading), but when I attempt to create the new ones I receive the following stacktrace:</p>
  <pre><code>Hibernate: 
    insert 
    into
      TABLE_1
      (key, col_A, col_B) 
  values
      (?, ?, ?)
  2011-08-31 17:35:09,089 [http-8080-1] DEBUG org.springframework.jdbc.support.lob.DefaultLobHandler IP134.167.141.34 CV#f2a597b2-a185-4e89 P#71252 - Set bytes for BLOB with length 7136
  2011-08-31 17:35:16,441 [http-8080-1] DEBUG org.springframework.jdbc.support.lob.DefaultLobHandler IP134.167.141.34 CV#f2a597b2-a185-4e89 P#71252 - Set bytes for BLOB with length 10946
  Aug 31, 2011 5:35:50 PM org.apache.catalina.core.StandardWrapperValve invoke
  SEVERE: Servlet.service() for servlet online threw exception java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into (&quot;SCHEMA&quot;.&quot;TABLE_1&quot;.&quot;COL_A&quot;)
  
  at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
  at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:396)
  at oracle.jdbc.driver.T4C8Oall.processError(T4C8Oall.java:837)
  at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
  at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
  at oracle.jdbc.driver.T4C8Oall.doOALL(T4C8Oall.java:523)
  at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:207)
  at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:1010)
  at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1315)
  at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3576)
  at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3657)
  at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1350)
  at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
  at org.apache.tomcat.dbcp.dbcp.DelegatingPreparedStatement.executeUpdate(DelegatingPreparedStatement.java:105)
  </code></pre>
  <p>Note the important piece where we see the lengths of the clobs immediately after the Hibernate insert statement from the generated SQL.</p>
  <p><strong>Edit</strong>: After looking at this early this morning, I realized that the issue was due to one of the Blobs had to be mapped with @JoinColumn(insertable = false, updatable = false), otherwise Hibernate would not start.  As such of course it was attempting to insert Null into this column.  So the new question becomes, can you lazily <strong>MULTIPLE</strong> clobs on a single table (using the same key).  I'm guessing without a table redesign, I'm pretty much out of luck unless Oracle fixes the driver.</p>