I'm trying to extend CrudRepository
to implement a soft delete feature. Referencing this Q&A, I made a repository interface like this:
@NoRepositoryBean
public interface SoftDeleteCrudRepository<T extends SoftDelete, ID extends Long> extends CrudRepository<T, ID> {
//...
@Override
@Query("update #{#entityName} e set e.delDT=current_timestamp where e.delDT is null and e.id=?1")
@Modifying
void deleteById(Long id);
//...
}
The method runs well, but the delDT
value doesn't contain offset value(eg. 2019-04-08 17:41:20.12 +00:00
).
I can change the JPQL to native query and use sysdatetimeoffset()
instead of current_timestamp
, but I want to keep using JPQL if I can.
How to set datetimeoffset values in JPQL?