<p>For a certain Hibernate entity we have a requirement to store its creation time and the last time it was updated.  How would you design this?</p>

<ul>
<li><p>What data types would you use in the database (assuming MySQL, possibly in a different timezone that the JVM)?  Will the data types be timezone-aware?</p></li>
<li><p>What data types would you use in Java (<code>Date</code>, <code>Calendar</code>, <code>long</code>, ...)?</p></li>
<li><p>Whom would you make responsible for setting the timestamps&mdash;the database, the ORM framework (Hibernate), or the application programmer?</p></li>
<li><p>What annotations would you use for the mapping (e.g. <code>@Temporal</code>)?</p></li>
</ul>

<p>I'm not only looking for a working solution, but for a safe and well-designed solution.</p>

A good approach is to have a common base class for all your entities. In this base class, you can have your id property if it is commonly named in all your entities (a common design), your creation and last update date properties.
For the creation date, you simply keep a
java.util.Date
property. Be sure, to always initialize it with
new Date()
.
For the last update field, you can use a Timestamp property, you need to map it with @Version. With this Annotation the property will get updated automatically by Hibernate. Beware that Hibernate will also apply optimistic locking (it's a good thing).