title: Insert with Hibernate native query does not work for java.util.Date
body: <p>I am using Hibernate JPA and Spring with a Mysql database and I want to insert using a SQL statement like this:</p>
  
  <pre><code>Date saveDate = new Date();
  java.sql.Timestamp timeStampDate = new Timestamp(saveDate.getTime());
  Query persistableQuery = entityManager.createNativeQuery("INSERT INTO TASK_ASSESSMENT (ACTIVE_FLAG, ASSESSMENT_DATE, DESCRIPTION, "
          + "TITLE, NEEDS_LEVEL_ID, PATIENT_ID, USER_ID) VALUES ("
          + true +", " + timeStampDate + ", " + description + ", " + title + ", "
          + needsLevelId + ", " + patientId + ", " + userId + " )");
  persistableQuery.executeUpdate();
  </code></pre>
  
  <p>But after running it I get the following error:</p>
  
  <pre><code>WARN : org.hibernate.util.JDBCExceptionReporter - SQL Error: -11, SQLState: 37000
  ERROR: org.hibernate.util.JDBCExceptionReporter - Unexpected token: 15 in statement
      [INSERT INTO TASK_ASSESSMENT (ACTIVE_FLAG, ASSESSMENT_DATE, DESCRIPTION, TITLE,
      NEEDS_LEVEL_ID, PATIENT_ID, USER_ID)
      VALUES (true, 2011-03-01 15?, any description, , 193, 1, 3 )]
  </code></pre>
  
  <p>Could someone help me on this please?</p>
  
  <p>PS. I am aware of using hibernate in non-native way, but I need to use native way. I am also of insert ...from... , but I don't think it will help.</p>
  
  <p>Finally I think the problem is mainly with the date. How do you guys pass on MySQL a <code>datetime</code> type using Java?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>The following works fine, I guess it is a java date to mysql datetime conversion problem.</p>
  
  <pre><code>("INSERT INTO TASK_ASSESSMENT "
       + "(ACTIVE_FLAG, ASSESSMENT_DATE, DESCRIPTION, TITLE, "
       + "NEEDS_LEVEL_ID, PATIENT_ID, USER_ID) "
       + "VALUES (true, 1999-12-22, '" + description + "', '" 
       + title + "', " + needsLevelId+", " + patientId 
       + ", " + userId + ")");
  </code></pre>
  
  <p>Could anyone please help me on how to convert <code>java.util.Date</code> to MySQL <code>datetime</code>?</p>