How to Set null Into QueryDSL Timestamp Column During Update?
java, querydsl, spring-data
Solution
Based on this QueryDSL issue: https://github.com/querydsl/querydsl/issues/846
I should use `setNull` method instead:
template.update(userAttempts, update -> update
.set(userAttempts.attempts, (short) 0)
.setNull(userAttempts.lastmodified)
.where(userAttempts.username.eq(username))
.execute()
);
Problem
I have the following table in Postgre: ``` CREATE TABLE user_attempts ( id INT PRIMARY KEY NOT NULL, username VARCHAR(50) NOT NULL, attempts SMALLINT NOT NULL, lastmodified TIMESTAMP, FOREIGN KEY ( username ) REFERENCES users ( username ) ); ``` I would like to update the `lastmodified` field through QueryDSL and Spring Data JDBC Extension as follow: ``` template.update(userAttempts, update -> update .set(userAttempts.attempts, (short) 0) .set(userAttempts.lastmodified, null) // compilation error here .where(userAttempts.username.eq(username)) .execute(); ``` However, it seems that QueryDSL's set method can't accept `null` because it will match more than one function signatures.