dimanche 22 février 2015

hibernate - making type of column in mysql only date and not datetime



I am storing date in mysql database using field of type DATE :



@Temporal(TemporalType.DATE)
@Column(name="RECIEVING_DATE")
private Date recieving_date;

// getters and setters


but when hibernate saves it , date is saved in type of datetime format, i.e. it doesn't store just 2015-02-23 but 2015-02-23 00:00:00.


Now , I can change type by running alter table query myself in database , but that will be painful every time. How can I tell hibernate to keep the type I want . And further , if this is possible , is it possible to define the size of varchar and integers using hibernate. Please help




Aucun commentaire:

Enregistrer un commentaire