Reputation: 591
How can I update a column in MySQL database with current timestamp value using Querydsl. Current value of this column is null
.
QCustomer customer = QCustomer.customer;
new JPAUpdateClause(session,customer).where(customer.name.eq("Bob"))
.set(customer.modified,????).execute();
Upvotes: 0
Views: 764
Reputation: 1423
It depends on the type you've defined for customer.modified
For Date:
QCustomer customer = QCustomer.customer;
new JPAUpdateClause(session, customer)
.where(customer.name.eq("Bob"))
.set(customer.modified, new Date())
.execute();
For Calendar:
QCustomer customer = QCustomer.customer;
new JPAUpdateClause(session, customer)
.where(customer.name.eq("Bob"))
.set(customer.modified, Calendar.getInstance())
.execute();
new Date() as well as Calendar.getInstance() return the current timestamp.
Upvotes: 2