Reputation: 3195
while updating datetime field using new Date()
function, it having date part but it time part will be (00.00.00
), Insertion it does,t have any problem 2013-08-02 12:57:09
,but in updation it works like 2013-08-02 00:00:00
....
session.createQuery(
"update DeviceDetails u set u.statusUpDate=:statusUpDate where u.id=:dID")
.setDate("statusUpDate", new Date())
.setInteger("dID",dID).executeUpdate();
session.getTransaction().commit()
Upvotes: 0
Views: 952
Reputation: 691735
Use setTimestamp()
, and not setDate()
.
Or don't use a query at all: get the entity using Session.get()
, and modify its fields.
Upvotes: 3