I store the date in mysql database using a field like DATE:
@Temporal(TemporalType.DATE)
@Column(name="RECIEVING_DATE")
private Date recieving_date;
but when sleep mode saves it, the date is stored in the date format type, i.e. not stored only on 2015-02-23, and 2015-02-23 00:00:00.
The code I use to insert the date
String recieving_date = request.getParameter("recieving_date");
DateFormat df = new SimpleDateFormat("yyyy-MM-dd");
java.sql.Date ds = null;
try {
Date date = df.parse(recieving_date);
ds=new java.sql.Date(date.getTime());
} catch (ParseException e1) {
System.out.println("Exception occured in parsing date : "+e1);
}
doc_mvmnt.setRecieving_date(ds);
Now I can change the type by running my own table query in the database, but it will be painful every time. How can I say that hibernation supports the type that I want. In addition, if possible, you can determine the size of varchar and integers using sleep mode. Please, help
source
share