how to update datetime colum (mssql) with formatted current datetime in querydsl

Viewed 31

I want to update datetime column with current datetime. but I've got an error at QAa.aaa.visitDt line. The data type of QAa.aaa.visitDt is DateTimePath<java.time.LocalDateTime>

```
    Date date = new Date();
    String updDt = DateFormatUtils.format(date, "yyyy-MM-dd HH:mm:ss");

    Long ret = queryFactory.update(QAa.aaa)
        .set(QAa.aaa.visitCnt, QAa.aaa.visitCnt.add(1))
        .set(QAa.aaa.visitDt, Expressions.dateTimePath(LocalDateTime.class, updDt))
        .where(QAa.aaa.aNo.eq(aNo))
        .execute();
Error Message is below.
 java.lang.IllegalArgumentException: org.hibernate.hql.internal.ast.QuerySyntaxException: unexpected token: ~
column 90 [update ~~
set aaa.visitCnt =aaa.visitCnt + ?1, aaa.visitDt= 2022-09-12 13:24:36.330
where aaa.aNo = ?3



0 Answers
Related