I have a datetime
field in my MySql database. A typical entry looks like this: 2015-08-26 11:45:48
.
But by the time it reaches my app the hours, minutes and seconds are always 00:00:00
.
This is the mapping entry:
<property name="listingTime" column="listing_time"/>
The field in my Java
class is
private java.sql.Timestamp startTime;
I tried setting various types for the listingTime
property in my hibernate.cfg.xml
but it doesn't change the all zeroes. What am I missing?
Better use annotations like this:
...
@Column
@Type(type="timestamp")
private Date listing_time;
OR you can do it this way, and if you don't want it to change see the "updateable"
@Column(name = "created", nullable = false, updatable=false)
@Temporal(TemporalType.TIMESTAMP)
private Date created;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With