Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Why are you using </p> <pre><code>Date date = new Date(); user.setLastLoginDate(new Timestamp(date.getTime())); </code></pre> <p>and not just this? </p> <pre><code>user.setLastLoginDate(new Date()); </code></pre> <p>First - You may not want to use Date and Timestamp at the same time.(e.g. for collections, etc)</p> <blockquote> <p>There are some classes in the Java platform libraries that do extend an instantiable class and add a value component. For example, java.sql.Timestamp extends java.util.Date and adds a nanoseconds field. The equals implementation for Timestamp does violate symmetry and can cause erratic behavior if Timestamp and Date objects are used in the same collection or are otherwise intermixed. The Timestamp class has a disclaimer cautioning programmers against mixing dates and timestamps. While you won’t get into trouble as long as you keep them separate, there’s nothing to prevent you from mixing them, and the resulting errors can be hard to debug. This behavior of the Timestamp class was a mistake and should not be emulated. (Bloch, Effective Java, 2nd Ed.)</p> </blockquote> <p>Second - I checked your examples, and it works fine for me on mysql-connector(5.1.21) / hibernate (4.0.1)</p> <p>I prepared simple test project with arquillian integration test(You need to prepare jboss before running it): <a href="https://github.com/rchukh/StackOverflowTests/tree/master/13803848" rel="nofollow">https://github.com/rchukh/StackOverflowTests/tree/master/13803848</a></p> <p>If you can provide some more information it might help - hibernate version, mysql version, mysql engine(MyISAM, InnoDB, etc.) Otherwise it is possible that this is just a misconfiguration.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload