title: DataIntegrityViolationException: could not execute statement; SQL nested exception is org.hibernate.exception.ConstraintViolationException
body: <p>i have a constraint problem with a foreign key. I have two object (User and UserSession) with a manyToOne relationship: an user can have many UserSession. I tried to insert a new UserSession but i got an DataIntegrityViolationException.</p>
  
  <p>Here is my usersession class:</p>
  
  <pre><code>public class UserSession implements Serializable {
  
      private static final long serialVersionUID = 1L;
  
      @Id
      @GeneratedValue(generator = "uuid2")
      @GenericGenerator(name = "uuid2", strategy = "uuid2")
      @Column(name = "id", columnDefinition = "VARCHAR(50)")
      private String userSessionUUId;
  
      other parameters ....
      @ManyToOne(targetEntity = User.class, fetch = FetchType.EAGER)
      @JoinColumn(name = "userUUId", referencedColumnName = "id", nullable = false)
      private User user;
  </code></pre>
  
  <p>my User class:</p>
  
  <pre><code>@Entity
  @Table
  public class User implements Serializable {
  
      some parameters
  
      @OneToMany(mappedBy = "user", targetEntity = UserSession.class, fetch = FetchType.LAZY)
      private List&lt;UserSession&gt; userSessions = new LinkedList&lt;&gt;();
  </code></pre>
  
  <p>The controller</p>
  
  <pre><code>@RequestMapping(value = "/path", method = RequestMethod.POST, consumes = "application/json")
  public void addUserSession(@RequestBody @Valid UserSession userSession) {
      object.createEntity(userSession);
  }
  </code></pre>
  
  <p>i posted this request: </p>
  
  <pre><code>curl -i -v -X POST -H 'Content-Type: application/json' -d '{othersparameters, "userUUId": "EEEEEE"}' http://localhost:8080/path 
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>[dispatcherServlet]: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [null]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement] with root cause
  com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Column 'useruuid' cannot be null
      at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
  </code></pre>
  
  <p>Can someone helps me?</p>
  
  <p>Cheers</p>