title: Can't deserialize DateTime in NativeQuery with Java / Hibernate
body: <p><em>Simplified examples</em></p>
  
  <p>I run a native query with date in it:</p>
  
  <pre><code>SELECT id, start FROM event;
  </code></pre>
  
  <p>I did a SqlResultSetMapping like:</p>
  
  <pre><code>@SqlResultSetMapping(
          name="EventMapping",
          classes={
                  @ConstructorResult(
                          targetClass=de.teamsystems.domain.OverviewEvent.class,
                          columns={
                                  @ColumnResult(name="id", type = Long.class ),    
                                  @ColumnResult(name="start", type = DateTime.class )
  
                          }
                  )
          }
  )
  </code></pre>
  
  <p>And my OverviewEvent class looks like:</p>
  
  <pre><code>@Entity
  public class OverviewEvent  {
  
      @Id
      private Long id;
  
      private String name;
  
  
      private DateTime start;
  
      public Long getId() {
          return id;
      }
  
      public DateTime getStart() {
          return start;
      }
  
      public OverviewEvent(Long id, DateTime start) {
          this.id = id;
          this.start = start;
      }
  </code></pre>
  
  <p>}</p>
  
  <p>When I execute this code in my controller, I get the following exception:</p>
  
  <pre><code>{
      "error": "Internal Server Error",
      "exception": "javax.persistence.PersistenceException",
      "message": "org.hibernate.type.SerializationException: could not deserialize",
      "path": "/event",
      "status": 500,
      "timestamp": "2017-03-13T22:22:30.527+0100"
  }
  </code></pre>
  
  <p>The log files say:</p>
  
  <pre><code>2017-03-13 22:22:30.523 ERROR 23479 --- [nio-8080-exec-1] o.a.c.c.C.[.[.[/].[dispatcherServlet]    : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed; nested exception is javax.persistence.PersistenceException: org.hibernate.type.SerializationException: could not deserialize] with root cause
  
  java.io.StreamCorruptedException: invalid stream header: 32303137
      at java.io.ObjectInputStream.readStreamHeader(ObjectInputStream.java:808) ~[na:1.8.0_111]
  </code></pre>
  
  <p>When I change the DateTime into String in the OverviewEvent class and in the SqlResultSetMapping, it works. But I would like to work with the datetime format.</p>
  
  <p>Does anyone can help me with that exception. I tried different things such as:</p>
  
  <pre><code>@Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
  @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
  private DateTime start;
  </code></pre>
  
  <p>But the exception stayed the same. Thanks for helping me out.</p>