title: Timestamp format must be yyyy-mm-dd hh:mm:ss[.fffffffff] when trying to select from db
body: <p>I have a simple select using sqlQuery and I am trying to map it to an entity. I do not understand what the problem is or what can I do about it and  I tried multiple sources from this site without any result</p>
  <p>function that takes the records</p>
  <pre><code>    public List&lt;MYTABLE&gt; getRecords(int first, int pageSize, String sortField, Map&lt;String, Object&gt; filters) throws DBEDatabaseException {   
  
          
          try {
              EntityManager em = getMyEmOrThrow();
              SQLQuery q = em.unwrap(SessionImpl.class).createSQLQuery(&quot;SELECT * FROM MYTABLE A where A.status = '1000'&quot;);
              q.addEntity(&quot;A&quot;, MYTABLE.class);
              q.setFirstResult(first);
              q.setMaxResults(pageSize);
              
              List&lt;MYTABLE&gt; results = q.list();
              
              return  results;
          }catch(RuntimeException e){
              throw new MyCustomException(&quot;Failure in getting records from table MYTABLE : &quot;, e);
      }
  
  
  ```
  Entity - **getters and setters and rest of the columns omitted** 
  @Entity(name = &quot;MYTABLE&quot;)
  @Table(schema = &quot;MYSCHEMA&quot;, name = &quot;MYTABLE&quot;)
  public class MYTABLE implements Serializable{
  
      @Column(name = &quot;TIMESTAMP&quot;, columnDefinition = &quot;TIMESTAMP (6)&quot;) // this column is the problem
      private Timestamp timestamp;
  
  }
  
  
  ```
  THIS DOESN'T WORK AS WELL
  
       @Column(name = &quot;TIMESTAMP&quot;, columnDefinition = &quot;TIMESTAMP (6)&quot;)
          @Temporal(TemporalType.TIMESTAMP)
          private Date timestamp;
  
  
  
  [Records in db look like this][1]
  
  
    [1]: https://i.stack.imgur.com/ahDmJ.png
  </code></pre>