title: DataIntegrityViolationException: not-null property references a null or transient value
body: <p>For some reason I'm getting this exception for a couple of records in my DB (&lt;10 when total > 30K).<br>
  I'm almost sure that this is not caused because of null values.<br>
  So my question is : "Is there any other reason to get this exception except null value"?  </p>
  
  <p>Here is my code:  </p>
  
  <pre><code>@Entity  
  @Table(name = "a")  
  @SequenceGenerator(name = "a_sequence", sequenceName = "a_sequence", allocationSize = 1)  
  public class A implements Serializable {
      @Id
      @Column(name = "id")
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "a_sequence")
      private Long id;
  
      @NotNull
      @ManyToOne
      @JoinColumn(name = "b")
      private B fieldB;
  }
  
  @Entity  
  @Table(name = "b")  
  @SequenceGenerator(name = "b_sequence", sequenceName = "b_sequence", allocationSize = 1)  
  public class B implements Serializable {
      @Id
      @Column(name = "id")
      @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "b_sequence")
      private Long id;
  
      @Column(name = "message")
      private String message;
  }
  </code></pre>
  
  <p>And here is my stack trace:</p>
  
  <pre><code>Caused by: org.hibernate.PropertyValueException: not-null property references a null or transient value: ***.***.domain.A.fieldB
      at org.hibernate.engine.Nullability.checkNullability(Nullability.java:100)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.scheduleUpdate(DefaultFlushEntityEventListener.java:309)
      at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:155)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
      at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
      at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
      at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
      at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
      at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
      at org.hibernate.ejb.TransactionImpl.commit(TransactionImpl.java:76)
      at org.springframework.orm.jpa.JpaTransactionManager.doCommit(JpaTransactionManager.java:512)
  </code></pre>
  
  <p><strong>Update:</strong>
  Code that causing an error</p>
  
  <pre><code>A a = getManager().find(A.class, id);  
  dozerBeanMapper.map(anotherAobject, a);  
  getManager().merge(a); 
  </code></pre>
  
  <p>Most likely that at second line fieldB at object a becomes null, but according to my logs this is not true, because fieldB in object anotherAobject is not null. The problem is that I have no possibility to connect to my app in debug mode. I have added more logs so that may give some information. 
  But if I'm right and after mapping from anotherAobject to a fieldB is not null, then what could cause this exception?</p>
  
  <p><strong>Update:</strong>  </p>
  
  <p>Issue was caused by a null value. Question closed.</p>