I’m not sure if I should be reporting this as a bug or not.
I’m trying to update a MySQL DATETIME field after some computations
dReturn = Mon Jun 30 16:28:59 EDT 2008
String dReturn = mySched.getLastRun().toString();
switch(mySched.getScheduleId()) {
case 1: DatabaseCount(); break;
case 2: DatabaseContent(); break;
case 3: FileCount(saSizeDirectory); break;
case 4: FileContent(saContentDirectory); break;
default: System.out.println(“No reports to run”);
}
TransactionStatus status = txManager
.getTransaction(new DefaultTransactionDefinition());
dao.update(mySched);
txManager.commit(status);
So, at the time of update mySched.getLastRun() has a full date time in it, but when I update the MySQL database, the time is going in as…
2008-06-30 00:00:00
… updated to the correct yyyy-mm-dd, but the time is always 00:00:00
Is the a dao bug? A MySQL bug? Am I doing something wrong? My setter/getter as generated by the reverse engineering is
@Temporal(TemporalType.DATE)
@Column(name = “last_run”, nullable = false, length = 0)
public Date getLastRun() {
return this.lastRun;
}
public void setLastRun(Date lastRun) {
this.lastRun = lastRun;
}