title: Cannot make @ManyToOne relationship nullable
body: <p>I have a many-to-one relationship that I want to be nullable:</p>
  
  <pre><code>@ManyToOne(optional = true)
  @JoinColumn(name = "customer_id", nullable = true)
  private Customer customer;
  </code></pre>
  
  <p>Unfortunately, JPA keeps setting the column in my database as NOT NULL. Can anyone explain this? Is there a way to make it work? Note that I use JBoss 7, JPA 2.0 with Hibernate as persistence provider and a PostgreSQL 9.1 database.</p>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>I found the cause of my problem. Apparently it is due to the way I defined the primary key in the referenced entity <code>Customer</code>:</p>
  
  <pre><code>@Entity
  @Table
  public class Customer { 
      @Id
      @GeneratedValue
      @Column(columnDefinition="serial")
      private int id;
  }
  </code></pre>
  
  <p>It seems that using <code>@Column(columnDefinition="serial")</code> for the primary key automatically sets the foreign keys referencing it to <code>NOT NULL</code> in the database. Is that really the expected behavior when specifying the column type as <code>serial</code>? Is there a workaround for enabling nullable foreign keys in this case?</p>
  
  <p>Thank you in advance.</p>