I\'ve got a class which contains an atttribute of java.time.LocalDateTime type.
public class MyClass{
// ...
private LocalDateTime fecha;
// ...
}
>
I had a similar question today (I was making SELECT, not a DELETE) and after posting it on here, I came up with two solutions:
@Query(value = "DELETE FROM MyClass mc WHERE DATE(fecha) =:fecha", nativeQuery = true)
public void deleteByFecha(LocalDate fecha);
Alternatively, following Cepr0's answer, I tested with success his solution:
default void deleteByFecha(LocalDate fecha) {
deleteByFechaBetween(fecha.atStartOfDay(), fecha.plusDays(1).atStartOfDay());
}
void deleteByFechaBetween(LocalDateTime from, LocalDateTime to);