Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JPA/hibernate time stamp not getting saved in database/object entity

I am using javax.persistence for my entity object.Mysql for database My entity object has a field entryDate

@Column(name = "ENTRYDATE")   
private Date entryDate=new Date();

and when i save the object using saveOrupdate method only the date gets saved. I also want to save the time stamp along with date. I do not explicitly set the date since i have already declared it along with the field declaration above. How can i get time also to be saved along with date.

Thank you.

like image 431
Arpan Solanki Avatar asked Jan 30 '11 14:01

Arpan Solanki


1 Answers

Use

@Temporal(TemporalType.TIMESTAMP) 

on your attribute.

like image 52
Daniel Avatar answered Sep 21 '22 01:09

Daniel