title: Java8 LocalDate JPA2.2 persisting to postgresql's Date fails when LocalDate is null
body: <p>I want to use <code>LocalDate</code> and <code>LocalDateTime</code> from Java8 DateTime API,
  and having trouble persisting to postgresql <code>date</code> and <code>timestamp</code> when values are <code>null</code>.</p>
  
  <p>Exception message:</p>
  
  <pre><code>Internal Exception: org.postgresql.util.PSQLException: ERROR: column "some_date" is of type date but expression is of type character varying
  hint: You will need to rewrite or cast the expression.
  position: 61
  Error Code: 0
  Call: INSERT INTO TEST (ID, some_date, some_timestamp) VALUES (?, ?, ?)
  bind =&gt; [0, null, null]
  Query: InsertObjectQuery(mypackage.TestEntity@38c9e0d6)
  </code></pre>
  
  <p>my maven dependencies for postgresql driver and JPA2.2:</p>
  
  <pre><code>&lt;dependency&gt;
          &lt;groupId&gt;org.postgresql&lt;/groupId&gt;
          &lt;artifactId&gt;postgresql&lt;/artifactId&gt;
          &lt;version&gt;42.2.0&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;org.eclipse.persistence.jpa&lt;/artifactId&gt;
          &lt;version&gt;2.7.1&lt;/version&gt;
  &lt;/dependency&gt;
  &lt;dependency&gt;
          &lt;groupId&gt;org.eclipse.persistence&lt;/groupId&gt;
          &lt;artifactId&gt;javax.persistence&lt;/artifactId&gt;
          &lt;version&gt;2.2.0&lt;/version&gt;
  &lt;/dependency&gt;
  </code></pre>
  
  <p>My <code>test</code> table at postgresql10.1 (there is NO <code>not null</code> constraint):</p>
  
  <pre><code>create table test (id serial, some_date date, some_timestamp timestamp);
  </code></pre>
  
  <p>My <code>TestEntity</code> class:</p>
  
  <pre><code>import javax.persistence.Column;
  import javax.persistence.Entity;
  import javax.persistence.Id;
  import java.time.LocalDate;
  import java.time.LocalDateTime;
  
  @Entity(name="test")
  public class TestEntity {
  
      @Id
      private int id;
  
      @Column(name="some_date")
      private LocalDate someDate;
  
      @Column(name="some_timestamp")
      private LocalDateTime someTimestamp;
  
     //simple getters and setters here.
  }
  </code></pre>
  
  <p>My <code>testMethod</code>:</p>
  
  <pre><code>public void testMethod() {
      TestEntity testEntity = new TestEntity();
      // IF I set both someDate and someTimestamp via setters,
      //I don't get any exceptions (table data will be added successfully)
      em.getTransaction().begin();
      em.persist(testEntity);
      em.getTransaction().commit(); //this is where the exception occurs.
  }
  </code></pre>
  
  <p>What am I missing? Is there any workaround for this?</p>
  
  <p><strong>Edit:</strong> 
  After months, I realized that this is problem does not occur any more. May be because I switched the server implementation from Grizzly to Payara5.181. 
  No custom converters required afterall (even if the value is <code>null</code>).</p>